URL RewriteRule in .htaccess for index.php query parameters

前端 未结 2 1635
礼貌的吻别
礼貌的吻别 2021-01-21 06:26

Example URL\'s:-

  • www.domain.com/index.php?bob
  • www.domain.com/index.php?jane
  • www.domain.com/index.php?fred

Need rewriting like:-

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-21 06:35

    You can use this code:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \s/+index\.php\?([^\s&]+) [NC]
    RewriteRule ^ %1? [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ index.php?$1 [L,QSA]
    

提交回复
热议问题