Forum Moderators: phranque
Here it goes:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]# Redirect to add "www" prefix for existing or new domain
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^secondsite\.com [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
# Internally rewrite new domain home page requests to a specific page
RewriteCond %{HTTP_HOST} ^www\.othersite\.com
RewriteRule ^$ /somefile.shtml [L]
</IfModule>
ErrorDocument 404 http://www.mywebsite.com/
Now I am getting the following errors
1. My wordpress blog is giving following error
Redirect LoopFirefox has detected that the server is redirecting the request for this address in a way that will never complete.
The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.
* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.
2. The errodocument is behaving in strange way i.e it is not redirecting to mywebsite.com but instead it redirects to mywebsite.com/blog with loop error.
Please solve this..I would be grateful to you guys...
Also, you cannot use a full URL in an ErrorDocument directive; If you do, then as documented, the server will respond with a 302-Found response, instead of a 404-Not Found. This can very seriously damage your search engine rankings.
I'd suggest:
ErrorDocument 404 /404-error.html
#
RewriteEngine on
#
# Externally redirect to add "www" prefix for existing or new domain
# and correct FQDN hostnames or hostnames with appended port number
RewriteCond %{HTTP_HOST} ^(mywebsite\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^(secondsite\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.com)\. [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.com):[0-9]+ [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
#
# Internally rewrite new domain home page requests to a specific page
RewriteCond %{HTTP_HOST} ^www\.othersite\.com
RewriteRule ^$ /somefile.shtml [L]
#
# If the requested URL does not resolve to an existing file or directory and we
# haven't already done so, rewrite the request to the /blog/index.php script
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
Jim