I have a WordPress install that uses a fairly vanilla .htaccess file. There are some files in a directory on the server that users should be able to access via a link sent in an email. That link contains URL variables, including a second URL. Something like:
www.mysite.com/email/email.php?src=http://source.com&title=sample
My mod_rewrite rules should allow access to it, but as long as the link contains '//' the user sees a 404 page on the WordPress site, rather than accessing the intended email.php file.
Here's the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
#RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_URI} ^/email$
RewriteRule . - [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
Any ideas on what I've done wrong?
Related
I do not usually in the habit of posting , because I always find my answer by searching the forums , but today I came across a real problem !
I have a Wordpress install multisite in a subdirectory of my domain. That is to say, it is at http://mondomaine.com/fr/ .
I wish to make a mobile version in a subdomain "m . " I want my mobile version is available at http://m.mondomaine.com/fr/ .
My host has created the subdomain m that points to the root of the site.
When I want to access a page from my mobile subdomain redirects it necessarily to the homepage /fr/ .
I tried to change my .htaccess , But nothing could be done , or I have a redirect loop , or I have a 404 page.
I suppose that there is a conflict between the rules , but I really tried and tested lots of solutions and I found nothing conclusive.
The original htaccess generated by Wordpress and located in the directory /fr :
RewriteEngine On
RewriteBase /fr/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
.htaccess that I modified:
RewriteEngine On
RewriteBase /fr/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteCond %{HTTP_HOST} !^m\.(.*) [NC]
RewriteRule . index.php [L]
RewriteCond %{HTTP_HOST} ^m\.(.*) [NC]
RewriteRule ^(.*)$ http://mondomaine.com/fr/$1 [L,P]
Thank you in advance to those who respond
If mod_proxy is enabled then move last m. rule right at the top, just below RewriteEngine On as this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\.(.+)$ [NC]
RewriteRule ^(.*)$ http://mondomaine.com/fr/$1 [L,P]
The hosting company I'm with has completely destroyed my .htaccess file about a month ago and while I managed to make most of it work again, I do not know how to add two exceptions to WordPress' wildcard subdomains (I use WordPress multisite). The hosting company is refusing to help me and, as a plain old web designer, I am not that good with rewrite rules and the server stuff and I never was.
This is the file - where do I add exceptions for approved.iva-is.me and love.iva-is.me?
<Files .htaccess>
order allow,deny
deny from all
</Files>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
Insert this rule just below RewriteBase / line:
# skip these 2 hosts
RewriteCond %{HTTP_HOST} ^(approved|love)\.iva-is\.me$ [NC]
RewriteRule ^ - [L]
I have a Wordpress network setup but currently there is only one subsite with the url
/psychology
In the future there will be addition sites with
/md
/vet
but for the time being there will only be /psychology
What I want to do is have a rewrite rule in my htaccess that when a user visits the root of the site (/) it actually loads the /psychology site.
I tried adding a line like this to my htaccess
RewriteRule (.*) psychology/$1 [R,L]
but it broke the site. here is my current htaccess (basically the wordpress default for a network install)
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Any ideas?
You need to add the base to the RewriteRule destination. And add a condition so you don't get a redirect loop.
Adding these two lines after RewriteRule ^ - [L] should work:
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
Here's the complete example:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
Your RewriteRule didn't work because it was matching all URLs, including ones to /psychology/foo. I'm guessing you don't have a .htaccess file under /psychology?
Try this - it'll rewrite just the root.
RewriteRule ^/$ psychology/ [r=301,L]
I'm having a minor but annoying issue with a site running WordPress 3.1.4 Multisite.
Navigating to the URI of a subpage without the "http://www" such as "abetterworldbydesign.com/2011-conference/" results in a redirect to the root "http://www.abetterworldbydesign.com".
The intent is for "abetterworldbydesign.com/2011-conference/" to redirect to "http://www.abetterworldbydesign.com/2011-conference/".
.htaccess file below (it's specific stuff for WordPress Multisite).
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress
Try adding this
RewriteCond %{HTTP_HOST} ^abetterworldbydesign.com
RewriteRule ^(.*)$ http://www.abetterworldbydesign.com/$1 [R=301,L]
at the very top, just after RewriteEngine On.
I want to write a RewriteRule to another RewriteRule, but I can't seem to get things to work. I'm having troubel with the line
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ render-product?url=$2 [L,NC]
in this file:
RewriteEngine On
RewriteBase /
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ render-product?url=$2 [L,NC]
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Basically, the url render-product is a url frendly url created by wordpress. I want something like ?url=RENDER/34324/4234/234234.html to be accessible on the wordpress page render-product via $_GET['url'].
What am i doing wrong?
RewriteRule ^(eTool/)?(RENDER/\d+/\d+/\d+/\d+\.html)$ index.php?pagename=render-product&url=$2 [L,NC]
I've suggested rewriting the URL to WP as query parameters, since WP won't parse the permalink of the rewrited URL, it will only examine the original URI request (if that makes sense!?).