Forum Moderators: phranque

Message Too Old, No Replies

modrewrite - remove URL endings completly!

For Joomla but its a general question

         

Pass the Dutchie

1:23 pm on Jan 30, 2007 (gmt 0)

10+ Year Member



Hi,

I use rewrites to disallow indexing of non-www. It works fine as follows.


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

I now want to rewrite http://www.example.com/fanpage/index.php to http://www.example.com/fanpage/

Please could someone point me in the right direction. I have crashed my server twice today and I've gone a little grayer ;)

Thanks for the help in advance.

PTD

[edited by: jdMorgan at 3:53 pm (utc) on Jan. 30, 2007]
[edit reason] example.com [/edit]

jdMorgan

3:56 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm guessing your coding attempt put your server into an 'infinite' redirection loop...

If so, does this [webmasterworld.com] help?

Jim

Pass the Dutchie

5:39 pm on Jan 30, 2007 (gmt 0)

10+ Year Member



hey Jim,

Nice it works for the home page. However it does not affect internal pages.


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.htm\ HTTP/
RewriteRule ^index\.htm$ http://www.example.com [R=301,L]

Do you know how to run this rule for all internal pages?

Thanks,

PTD

[edited by: Pass_the_Dutchie at 5:41 pm (utc) on Jan. 30, 2007]

jdMorgan

5:51 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please define "all internal pages."

Do you mean every single page on the site?

Jim

Pass the Dutchie

8:00 pm on Jan 30, 2007 (gmt 0)

10+ Year Member



yes thats right, all pages on the site.

jdMorgan

10:02 pm on Jan 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is probably what you want:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.htm\ HTTP/
RewriteRule ^(([^/]*/)*)index\.htm$ http://www.example.com/$1 [R=301,L]

However, this redirects only index.htm pages, and not all pages on the site -- That would cause major problems when you redirected robots.txt to an htm or php page.

Jim

Pass the Dutchie

2:04 pm on Jan 31, 2007 (gmt 0)

10+ Year Member



Hi Jim,

Thats exactly what I was trying to do. Sorry I forgot to mention that I just wanted to rewrite the .htm extensions. Anyway, many many thanks to you and WW.

Cheers

PTD