Forum Moderators: phranque
//------------start------------------//
redirect /index.php http://www.example.com/forums/
//-------------end------------------//
[edited by: jdMorgan at 5:06 am (utc) on Aug. 19, 2005]
[edit reason] Examplified. [/edit]
Jim
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/$ /forums/ [L]
I would suggest:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [OR]
RewriteRule ^(index\.php)?$ /forums/ [L]
Combined the conditions and made the www optional, so either will qualify for the single rule.
Escaped the special character .(dot) (EG \.) - .(dot) in regex is 'any character except the end of a line'
Cond: Check to see if the accessed domain is www.yoursite.com or yoursite.com - if it is, continue with the rewrite. If not, the condition will fail.
Rule:
Removed / (stripped by Apache before the .htaccess comparrison is made, so nothing will match if it is present.)
Added (index\.php)? - () = group. ? = 0 or 1 of the preceding characters or group of characters. index\.php is the main index, so by grouping and making the group optional, any access to yoursite/ or yoursite/index.php will qualify for the rewrite.
If this is supposed to be an external (seen in the browser) redirect, then adding R=301 to the L flag is necessary. EG [R=301,L]
Hope this helps. You really were very close =)
Justin