I have a site running on WordPress. I am testing out a new site on our server under a subdirectory (sandbox/). For the new site I’m using an .htaccess rewrite rule similar to WP that rewrites to clean urls. I’m finding that pages that have an equivalent path in WP redirect to the WP page.
For instance, I have one page that has an url of /sandbox/supplies/information which redirects correctly to the new site. However, I have another page that is at /sandbox/events/ that will redirect to the base director at /events/.
After looking around at people’s similar problems, I’ve tried using RewriteCond %{REQUEST_URI} !sandbox/ [NC] and other variants (!^sandbox/.$ and the like), but it doesn’t seem to have any effect whatsoever. I’ve copied the two .htaccess files below.
Thanks in advance for your time. I hope I explained the situation well enough.
Base .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !sandbox/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Sub-directory (sandbox/) .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sandbox/index.php [L]
Well .. I have only used this line in main .htaccess file, and it all worked fine on my simulated setup:
May I suggest changing
Options +FollowSymLinkstoOptions +FollowSymLinks -MultiViews(or maybe you have tried that already)?If URL has
/sandbox/part and your/sandbox/.htaccessdoes not haveRewriteOption inheritline, then rules from parent .htaccess are NOT getting used at all.How much control do you have over Apache? Can you edit config files (httpd.conf or httpd-vhost.conf)? If you can — enable rewrite debugging (
RewriteLogLevel 9) and try that problematic URL — you should see exactly what is going on (maybe it getting redirected from within php application?). Other than that your rules are absolutely fine for me.Don’t know if this is good idea or not .. but in case you will be unable to figure out the reason for such behaviour, consider joining these 2 .htaccess files into 1 (changes are minimal).