【问题标题】:htaccess remove index.php from url/folderhtaccess 从 url/文件夹中删除 index.php
【发布时间】:2019-03-14 04:35:21
【问题描述】:

我有一个问题,在互联网上找不到可行的解决方案。所以希望你能帮助我。

我需要使我的网站尽可能对 SEO 友好。因此我需要更改以下内容

https://www.example.com/index.php
https://www.example.com/folder/index.php
https://www.example.com/folder/folder/index.php

收件人:

https://www.example.com/
https://www.example.com/folder/
https://www.example.com/folder/folder/

我需要一些规范的重定向,以便我的网站只能在没有 /index.php 的情况下访问,以消除重复的内容。

我想使用 .htaccess。很感谢任何形式的帮助。 提前致谢。

【问题讨论】:

    标签: php .htaccess redirect mod-rewrite file-extension


    【解决方案1】:

    只需在主域 (www.example.com/) 中创建 .htaccess 并放入以下代码。

    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
    RewriteRule ^ /%1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-20
      • 2017-03-15
      • 1970-01-01
      • 1970-01-01
      • 2020-02-08
      • 2021-10-02
      • 2015-01-20
      相关资源
      最近更新 更多