繁体   English   中英

htaccess从网址/文件夹中删除index.php

[英]htaccess remove index.php from url/folder

我有问题,无法在互联网上找到有效的解决方案。 所以希望你能帮助我。

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

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。 很感谢任何形式的帮助。 提前致谢。

只需在主域(www.example.com/)中创建.htaccess,然后将其放在下面的代码中即可。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM