How can I make these .htaccess rules work together?
I have two separate sets of .htaccess rules. One set tells example.com to
point all but a select few url requests to a subdirectory in my hosting
account where my main site lives, and the other set are .htaccess rules
required for Wordpress, which is installed in the root, to format links
properly.
The problem is that I can't use the Wordpress rules as-is because in doing
so I'll lose access to my main site. I've been trying to figure out a way
to have all requests BUT those tied to Wordpress redirect to the
subdirectory. The closest I've come is the second line of code in the
first sample below, but it's not working: WP requires its .htaccess rules
in order to format the links properly.
So how can I adjust these rules so that the two sets of code will play
nice together? I've been trying to figure this out for four days but I
know nothing about .htaccess and I'm at the end of my rope. I'd be so
grateful if anyone could help me fix this.
The .htaccess I'm currently using:
RewriteEngine on
RewriteRule ^(wp-(content|admin|includes)|site1|site2|site3) - [L]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/index.php [L]
The .htaccess I need to safely integrate into that one:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
No comments:
Post a Comment