Forum Moderators: phranque
[webmasterworld.com...]
Unfortunately it doens't work so well with an installation of a popular blog software. domain.com redirects to www.domain.com fine, but domain.com/blog-post/ redirects to www.domain.com/index.php, and www.domain.com/index.php does not redirect to www.domain.com. Here is the original .htaccess that comes with the blog software:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
Here's the htaccess code that I'm trying to integrate with that:
RewriteEngine on
RewriteBase /
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]
#
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Anyone know how this can be accomplished?
[edited by: encyclo at 2:25 am (utc) on Nov. 13, 2006]
[edit reason] examplified, see TOS [webmasterworld.com] [/edit]
Then put the two redirects ahead of the blog rewrite -- That should work.
Note also that this forum deletes required space characters between "}" and "!" in code posted here.
Jim
RewriteEngine on
RewriteBase /
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.php\ HTTP/
RewriteRule index\.html$ [domain.com...] [R=301,L]
#
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
/index.php still doesn't redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.[b]php[/b]\ HTTP/
RewriteRule index\.[b]html[/b]$ http://www.domain.com/%1 [R=301,L]
Note that "index\.html" in both lines of the first redirect should probably be changed to "index\.php" for the site you described.
The patterns for the file extensions in both lines must match, or the rule will never be invoked:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.[b]php[/b]\ HTTP/
RewriteRule index\.[b]php[/b]$ http://www.domain.com/%1 [R=301,L]