How to merge WP sub-dir htaccess with my ROOT htaccess
-
Right so I’ve installed wordpress into a /content DIR off my root and built it up under there. Now when I wanted to go live I attempted to follow the ‘Using a pre-existing subdirectory install’ guide but it didn’t work.
The problem should be easy to fix but I rarely fiddle with .htaccess so let me explain. In the /content dir my .htaccess is:
AddType x-mapp-php5 .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /content/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /content/index.php [L] </IfModule> # END WordPress
But the problem is that my ROOT .htaccess already uses Rewrite rules that conflict. Here’s a shortened example of my ROOT .htaccess:
AddType x-mapp-php5 .php ErrorDocument 404 http://www.mysite.com/e404.shtml ErrorDocument 403 http://www.mysite.com/e403.shtml RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301] RewriteRule ^cgi-bin/polls/archive.html /cgi-bin/polls/_polls.cgi?archives=1 [L]
WP’s guide suggests to MOVE my /content .htaccess into the root, so naturally for me I need to merge the two. At first I tried to put the following in my ROOT .htaccess (it was all pasted directly below “RewriteRule ^(.*) http://www.ispreview.co.uk/$1 [L,R=301] “):
RewriteBase /content/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /content/index.php [L]I had to remove “RewriteBase /content/” as that caused too many problems with existing scripts and files. Now almost everything works but for two problems.
1) I have a ton of redirects that now return 404 errors. Just one is shown in my example (” RewriteRule ^cgi-bin/polls/archive.html /cgi-bin/polls/_polls.cgi?archives=1 [L] “). This is no doubt related to the confusion caused by telling my site to look in /content, but how do I fix it? I tried adding “content/cgi-bin/polls… etc.” at the start (in both the root and /content .htaccess) but that didn’t work. What do I do?
2) If somebody types http://www.mysite.com/index.shtml (this was my old static index file before I removed it for WP’s index.php) it, unlike before, no longer automatically redirects to index.php and just shows a 404 error. So I need calls to the index.html / index.shtml files to link into the correct index.php (i.e. http://www.mysite.com).
Can anybody help?
PS – I have several domains that link into my site so for various obvious SEO etc. reasons I can’t afford to lose these as they tell my other domains to become http://www.mysite.com. This is v.important:
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301]
- The topic ‘How to merge WP sub-dir htaccess with my ROOT htaccess’ is closed to new replies.