Welcome to WebmasterWorld Guest from 3.94.129.211

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

want to eliminate 'index.php'

...actually, to just keep it from showing

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

Preferred Member

10+ Year Member

joined:Jan 4, 2004
posts:456
votes: 0


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]

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

Senior Member from MY 

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 1, 2003
posts:4847
votes: 0


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.

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

Preferred Member

10+ Year Member

joined:Jan 4, 2004
posts: 456
votes: 0


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?

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


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

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

Preferred Member

10+ Year Member

joined:Jan 4, 2004
posts: 456
votes: 0


jdMorgan,

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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members