htaccess redirect index.php to root (including subdomains)

前端 未结 3 564
渐次进展
渐次进展 2020-12-02 09:23

I\'m trying to redirect index.php files to the root /, I\'ve searched around and found several snippets of code similar to:

RewriteCond %{THE_REQUEST} ^.*/in         


        
相关标签:
3条回答
  • 2020-12-02 09:58

    I based the following code on @ThinkingMonkey's answer

    RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L]
    

    It redirects URIs ending with index.php, index.htm or index.html to /. Works with subdirectories, too.

    Also, notice the NC flag. It makes it case-insensitive. So it works even if the URI is in upper-case such as INDEX.PHP.

    0 讨论(0)
  • 2020-12-02 10:04

    Can be use this

    RewriteRule ^index\.php/(.*)$ http://www.example.com/$1 [R=301,L]
    
    0 讨论(0)
  • 2020-12-02 10:13

    Do this:

    RewriteCond %{THE_REQUEST} ^.*/index\.php 
    RewriteRule ^(.*)index.php$ /$1 [R=301,L] 
    
    0 讨论(0)
提交回复
热议问题