Forum Moderators: phranque

Message Too Old, No Replies

Help me remove index.htm

.htaccess codes for some 301 redirection

         

hgupta

9:44 am on Jan 5, 2007 (gmt 0)

10+ Year Member



Hello Jaz,

I am Himanshu Gupta; from last few days i am quite busy finding the correct re-write ruls for some redirections to avoid duplicate content & some other problems; I saw the rewrite rules in this URL:
[webmasterworld.com...]

Please advice what to do in my .htaccess (under apache) to make the following changes:

------------------------

1 - Add extra slashes in URL (http://www.example.com/123//index.html)

2- Remove index.html from URL (http://www.example.com/123/index.html >> change to >> http://www.example.com/123/)

3 - 301 Redirect from www. to non www. or vice versa. (Have fixed it, please check if it’s wrong or if there is any other good command)

\\\\\\\\\\\\\\\\\\

Please let me know the codes separately for each task (above written) through .htaccess file; my .htaccess has the following code in it

---------------------------------------------------------------------

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com$1 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.htm$ / [R=301,L]
ErrorDocument 404 /error.htm

---------------------------------------------------------------------
Please please, show me the exact way to fix these problems; specially:

Remove index.html from URL (http://www.example.com/123/index.html to http://www.example.com/123/)

I will be thankful of you. Thanks…

Kind Regards…
Himanshu Gupta

[edited by: engine at 10:32 am (utc) on Jan. 5, 2007]
[edit reason] examplified, see TOS [webmasterworld.com] [/edit]

phranque

10:24 am on Jan 5, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you can try this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{ENV:myURI} ^(/([^/]+/)*)index\.html [NC]
RewriteRule ^(/([^/]+/)*)index\.html http://www.example.com/$1 [L,R]