Forum Moderators: phranque

Message Too Old, No Replies

Reject direct requests using mod rewrite

         

adrek

10:28 pm on Apr 8, 2009 (gmt 0)

10+ Year Member



Im making a website for a friend and one of the things he wanted was extentionless urls and disable the use of the direct request. like [somedomain.com...] will work but [somedomain.com...] will not work

i spent a couple of days searching google but have not been able to find anything. Here is the rewrite code. does anyone have any suggestions?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([^./]+)+)/?$ $1.php [L]

Thanks Andrew.

jdMorgan

10:35 pm on Apr 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Search this forum (link at top of page) for "direct client requests RewriteCond THE_REQUEST" (no quotes) for many examples.

As this is an external redirect, it must be placed before your internal rewrite code above.

Jim

adrek

8:07 pm on Apr 10, 2009 (gmt 0)

10+ Year Member



ok ill try that, Thanks!