Sunday, 15 April 2012

.htaccess - return 404 if .php is requested -



.htaccess - return 404 if .php is requested -

my .htaccess file looks in order create urls /something.php /something :

options -multiviews rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ $1.php [l]

when requested php extension, still works. how can homecoming 404 if .php extension requested? give thanks you.

first, approach should shortened to:

rewritecond %{request_filename}.php -f rewriterule ^(.*)$ $1.php [l]

this probes existence of .php file, not absence of basename.

since [last] rule, can afterwards (or perchance before rewriterule/rewritecond block) probe already-present .php suffixes:

rewriterule ^(.*)\.php$ - [f]

... or issue redirect in such cases.

php .htaccess

No comments:

Post a Comment