删除 htaccess 中的特定查询字符串键

Remove specific query string key in htaccess

我想进行重定向 url

来自

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

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

有什么想法吗?

想要删除文本

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

您可以在 /admin/.htaccess 文件中使用此代码:

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=&action= [L,QSA]