Forum Moderators: phranque
I have a website running Joomla on the root of my public_html folder.
I need to run another site that will be located on a subfolder of my public_html, like this:
public_html/otherexample
The .htaccess Joomla generated is redirecting the acesses to a 301 error page when i try to access this other site.
On the .htacess file there's the following code:
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
How can i write the following:
If the host is www.otherexample.com, open this site as usual, but if it's anything else, keep the code above?
[edited by: jdMorgan at 11:19 pm (utc) on Aug. 28, 2009]
[edit reason] example.com [/edit]
# Redirect to canonical domain if the requested hostname contains "otherexample.com" but is non-canonical
RewriteCond %{HTTP_HOST} otherexample\.com [NC]
RewriteCond %{HTTP_HOST} !=www.otherexample.com
RewriteRule ^(.*) http://www.otherexample.com/$1 [R=301,L]
#
# Else redirect to canonical domain if the requested hostname contains "example.com" but is non-canonical
RewriteCond %{HTTP_HOST} example\.com {NC}
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Note that regex patterns and string-match patterns have different syntax; The literal periods in regex patterns must be escaped as shown, and the literal periods in string-match patterns must NOT be escaped.
Jim