简体   繁体   中英

How to clean url variable with htacces

I have a link like this: http://localhost/dimi/home?go=post&app=tagline&post_id=222

How do I rewrite the url to look like this: http://localhost/dimi/home/post/tagline/222

What tried is:

RewriteEngine On
RewriteRule ^home$ home.php [L]
RewriteRule ^home/([^/]+)/?$ home.php?go=$1 [L,NC]

I just want to hide the variables for security purposes.

Thank you

Try it like this in dimi directory.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\d]+)$ $1.php?go=$2&app=$3&post_id=$4 [QSA,NC,L]

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