I have a site that uses subdomains to facilitate the housing of multiple wordpress blogs. Each blog is in a subdirectory, directly off the site root.
I need to do a multi-step rewrite. What I now have works, but I would like to strip some of the resulting URL just to make the URL look nice.
here’s what I now have
RewriteCond %{HTTP_HOST} ^newblog\. myblogsite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/newblog/
RewriteRule ^(.*)$ /vservers/myblogsite/htdocs/newblog $1 [L]
This works, but my resulting URL looks like this:
h t t p ://newblog.myblogsite.com/newblog/
And I would like it to look like this:
h t t p ://newblog.myblogsite.com/
My htaccess file is in the site root directory. Should I put another htaccess file in the newblog directory?
It looks to me like you’ve mixed apples and oranges in your redirection (ALWAYS use the VirtualDomain’s DocumentRoot, NOT the physical address on the server).
Remember, to use the newblog subdirectory, it’s a subdirectory of myblogsite.com, not of newblog.myblogsite.com! newblog is the DocumentRoot of its own subdomain!
If you decide to redirect to http://myblogsite.com/newblog, just remember that the request MUST pass through myblogsite’s .htaccess enroute to newblog so it’ll be subjected to any mod_rewrite you may have there (if another WP blog, you WILL LOSE the newblog subdirectory as WP redirects EVERYTHING to its own index.php (in the directory, here DocumentRoot, where the .htaccess resides).
RewriteEngine on
RewriteCond %{HTTP_HOST} ^newblog\\. myblogsite\\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/newblog/
RewriteRule ^(.*)$ http://myblogsite.com/newblog/$1 [L]
# OR RewriteRule .? http://myblogsite.com/newblog%{REQUEST_URI} [L]
[COLOR="Red"]# BUT don't forget to check for !-f and !-d in either case![/COLOR]