clean URL using .htaccess

前端 未结 3 515
闹比i
闹比i 2021-01-14 21:09

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

相关标签:
3条回答
  • 2021-01-14 21:43

    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]
    
    0 讨论(0)
  • 2021-01-14 21:51

    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]
    
    0 讨论(0)
  • 2021-01-14 21:55

    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]
    
    0 讨论(0)
提交回复
热议问题