简体   繁体   中英

Rewrite based on Query Parameters

I using PHP on IIS Server and I need to rewrite a url with query parameters to url without query parameters

My url is: http://localhost/?page=info and I want that open http://localhost/info

I think you can use this 1st you need to make rewrite engine enabled on your php config on server 2nd make .htaccess file then put this code in it

RewriteEngine On
RewriteRule ^/?page/([^/]+)/?$ index.php?page=$1 [L,QSA]

maybe that answer your question? hope so

Put this code into .htaccess file. To keep the prefix and replace the last part with a query string

RewriteCond %{QUERY_STRING} !^id=
RewriteRule ^root/pages/(.+)$ /root/pages/?id=$1 [L]

The RewriteCond is needed to prevent a rewrite loop.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM