Reputation: 442
I currently use the following htaccess code to remove all .php extensions:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+[^/])/?$ $1.php [L]
ive been trying to use the following htaccess code to internally redirect or add a hidden query parameter to a file
RewriteRule ^myfile/?([^/])?/?$ myfile.php?m=$1 [L]
but it does not work.
Upvotes: 2
Views: 165
Reputation: 785196
Order of rules in .htaccess is important so your new rule should be above all other rules. This should be your .htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^myfile/?([^/])?/?$ myfile.php?m=$1 [L,QSA,NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+[^/])/?$ $1.php [L]
Upvotes: 1