I have the following problem when I try to create a user-friendly URL, it returns a 500 error.
Doesn’t work
RewriteEngine On
RewriteRule ^page/(.+)$ /page.php?type=$1 [L]
Works this one only if I change the script name
RewriteRule ^page/(.+)$ /change-page.php?type=$1 [L]
Is there any way to keep page.php that redirects to page? Thank you
Here the full .htaccess configuration
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# For LocalHost !.php
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=::1
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ %1 [R=302,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
RewriteRule ^page/(.+)$ /page.php?type=$1 [L]
2
Answers
You should try following rules in your .htaccess file. Please make sure to clear your browser cache before testing your URLs.
Try these rules: