clean URL using .htaccess

只愿长相守 提交于 2019-12-01 11:23:21

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]

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]

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]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!