[英]htaccess remove index.php from url/folder
I have a problem and couldn't find a working solution on the internet. 我有问题,无法在互联网上找到有效的解决方案。 So hopefully you can help me. 所以希望你能帮助我。
I need to make my website as SEO friendly as possible. 我需要使我的网站尽可能友好。 Therefore I need to change the following 因此,我需要更改以下内容
https://www.example.com/index.php
https://www.example.com/folder/index.php
https://www.example.com/folder/folder/index.php
To: 至:
https://www.example.com/
https://www.example.com/folder/
https://www.example.com/folder/folder/
I need some kinda canonical redirect so that my website is only accessible without the /index.php in order to eliminate duplicate content. 我需要某种规范的重定向,以便仅在没有/index.php的情况下才能访问我的网站,以消除重复的内容。
I would like to use .htaccess. 我想使用.htaccess。 Any help is very much appreciated. 很感谢任何形式的帮助。 Thanks in advance. 提前致谢。
Just create .htaccess in the main domain (www.example.com/) and put below code. 只需在主域(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.