URL RewriteRule in .htaccess for index.php query parameters

前端 未结 2 1602
礼貌的吻别
礼貌的吻别 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:33

    You can also use this:

    RewriteEngine On 
    
    RewriteCond %{REQUEST_FILENAME} !-f 
    
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
    
    0 讨论(0)
  • 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]
    
    0 讨论(0)
提交回复
热议问题