I\'m trying to redirect the links on my domain. What I\'m trying to achieve is: When the user clicks on a link to
mydomain.com/index.php?dir=myfolder
Just append this rule at the end of your existing .htaccess file:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?dir=([^\s]+) [NC]
RewriteRule ^ %1? [R=301,L]
To prettify URLs of the format mydomain.com/index.php?dir=myfolder
as mydomain.com/myfolder
, try the following rewrite rule in your .htaccess
file:
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?dir=$1 [L]
I think you question is about making /index.php?dir=example
redirect to /example
. The below example issues a permanent redirection:
RewriteRule ^index\.php\?dir=?$ /$1 [NC,R=301,L]