简体   繁体   中英

Remove specific query string key in htaccess

I want to make a redirect url

From

http://abc.redirect.in/admin/index.php?controller=class&action=add

To

http://abc.redirect.in/admin/class/add

Any idea?

Want to remove text

http://abc.redirect.in/admin/ index.php?controller= class &action= add

You can use this code in your /admin/.htaccess file:

RewriteEngine On
RewriteBase /admin/

RewriteCond %{THE_REQUEST} /admin/index\.php\?controller=([^\s&]+)&action=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/([^/.]+)/?$ index.php?controller=$1&action=$1 [L,QSA]

Check this out. .htaccess magic examples on Github: https://github.com/phanan/htaccess

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