Raviranjan Mishra
Raviranjan Mishra

Reputation: 857

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

Upvotes: 1

Views: 383

Answers (1)

anubhava
anubhava

Reputation: 786091

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]

Upvotes: 2

Related Questions