I want to change
http://example/index.php?name=phone
to
I tried this:
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?name=$1
It actually allows me to use example/phone
but it's not forcing a redirect when I use example/index.php?name=phone
I want to be able only to get to the clean url. When I write the non-clean url it should redirect me to the clean url.
Edit
i'll try to simplify the question . what i want is when i write
example/index.php?name=phone
it redirects me to
example/phone
and of course , 'phone' is a variable .
here you go :
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?name=$1 [L]
This works :
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?name=([^\s]+) [NC]
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?name=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?name=$1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.