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

时间:2015-02-26 20:01:42

标签: regex apache .htaccess mod-rewrite redirect

我想制作一个重定向网址

发件人

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= {类{1}}添加

2 个答案:

答案 0 :(得分:2)

您可以在/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=$1&action=$1 [L,QSA]

答案 1 :(得分:0)

检查一下。 Github上的.htaccess魔术示例:https://github.com/phanan/htaccess