Jumble Solver url重写

时间:2017-10-20 11:09:35

标签: php .htaccess

我想做以下事情:

  1. 每个网址都是非www版本。 所以,当有人会搜索 https://www.englishact.com/DifferentLiterature/

    它会自动重定向到

    https://englishact.com/DifferentLiterature/

  2. Url会忽略index.php

    示例:

    https://www.englishact.com/jumblesolver/index.php

    将被重定向到

    https://englishact.com/jumblesolver/

  3. 问题1解决了。需要编辑第二个条件(2)

    这是我目前的htaccess代码

    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    RewriteRule https://www.englishact.com/jumblewordsolver/index.php https://englishact.com/jumblewordsolver/ [L,R=301] 
    

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteBase /

# Redirect /index.php to /
RewriteRule ^(.+/)?index\.php$ https://englishact.com/$1 [NC,L,R=301] 

# Redirect without www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,R=301,L]