Bobby
asked on
301 redirect mod_rewrite to strip /index.html, will this snippet work?
I want any request that goes to mysite.com/index.html to be 301 redirected to mysite.com
Will the following mod_rewrite work in my htaccess file, is it comprehensive enough, and where would it need to be placed in the file?
RewriteCond %mysite.com/index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
Will the following mod_rewrite work in my htaccess file, is it comprehensive enough, and where would it need to be placed in the file?
RewriteCond %mysite.com/index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
ASKER
David,
I dont understand. Are you saying that what i posted will not do what i said we need to do?
I dont understand. Are you saying that what i posted will not do what i said we need to do?
if index.html is your default page then
http://mysite.com and http://mysite.com/index.html is exactly the same as the web server when given http://mysite.com will load the default document if it exists.
What page do you want the web server to load?
http://mysite.com and http://mysite.com/index.html is exactly the same as the web server when given http://mysite.com will load the default document if it exists.
What page do you want the web server to load?
Likely what you're looking for is something like this...
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.php$ http://www.domain.com/$1 [R=301,L]
ASKER
This is for SEO reasons... I know the server will already do that but we want results displayed without the /index.html and this may help with that.
David F, that looks exactly like where I got this:
RewriteCond %mysite.com/index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
You think that will do it? Do you know where in the htaccess file it needs to go? Im not even sure how you test something like this.
David F, that looks exactly like where I got this:
RewriteCond %mysite.com/index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]
You think that will do it? Do you know where in the htaccess file it needs to go? Im not even sure how you test something like this.
ASKER
Ended up doing this, seems to work well:
RewriteRule ^index.html$ / [L,R=301]
Thanks all for the tips.
RewriteRule ^index.html$ / [L,R=301]
Thanks all for the tips.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you want to change it in your httpd.conf i.e.
DirectoryIndex home.php