Forum Moderators: phranque

Message Too Old, No Replies

want to eliminate 'index.php'

...actually, to just keep it from showing

         

Storyman

3:06 am on Jun 20, 2007 (gmt 0)

10+ Year Member



When the code below is inserted into the .htaccess file it creates an internal server error.

What it is suppose to do is when a user enters sitename.com/index.php or sitename.com/index.html it should display just sitename.com/.

Any ideas on what I'm doing wrong

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\.*/index\.(php¦html)\HTTP
RewriteRule ^(.*)index\.(php¦html)$/$1 [R=301,L]

vincevincevince

3:12 am on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\.*/index\.(php¦html)\HTTP
RewriteRule ^(.*)index\.(php¦html)$ /$1 [R=301,L]

Missing space, line 3. Ensure the ¦ is replaced with a solid one when you use it.

Storyman

4:45 am on Jun 21, 2007 (gmt 0)

10+ Year Member



Thanks for replying.

Can't figure it out. It doesn't seem to matter what I try the code just will not work. Replaced the vertical 'or' argument with a solid vertical bar.

Can you think of any reason that it will not work?

jdMorgan

6:06 am on Jun 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are a couple additional problems, first the RewriteCond pattern is missing two spaces, which completely changes it's function, and second, the substitution URL form isn't right for an external redirect:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*index\.(php¦html)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php¦html)$ http://www.example.com/$1 [R=301,L]

I also tweaked the path-to-index patterns for speed.

IF there are no other RewriteRules in the file (i.e. these are your first rules), then you may need to add


Options +FollowSymLinks

before the RewriteEngine directive. If this is required by your server config, you'll get a 500 Error if it's missing -- Check your server error log to confirm.

Same deal as usual -- fix the pipes. :)

Jim

Storyman

6:16 am on Jun 21, 2007 (gmt 0)

10+ Year Member



jdMorgan,

Wow! That did the trick. Thank you very much.