Forum Moderators: phranque
RewriteRule ^about/?$ /about.php [NC,L]
RewriteRule ^search/?$ /search.php [NC,L]
So if the user types
www.mysite.com/about he receives about.php data. Till there no problem at all.
But, if the user types (directly)
www.mysite.com/about.php i need the htaccess to send a 404 Not Found msg. How can i do that?
Jim
[edited by: jdMorgan at 5:14 pm (utc) on Sep. 24, 2006]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*[^/.]+\.php
RewriteRule \.php /path_to_file_that_does_not_exist.hph [L]
A request for any .php file, in any subdirectory, will return a 410-Gone (indicates that the requested resource was intentionally removed):
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*[^/.]+\.php
RewriteRule \.php - [G]
A request for any .php file, in any subdirectory, will return a 301-Moved Permanently redirect to the "proper" path with ".php" removed:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*[^/.]+\.php
RewriteRule ^(.+)\.php$ http://www.example.com/$1 [R=301,L]
Jim