doubanduo7620 2019-03-14 04:35
浏览 80
已采纳

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

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.

I would like to use .htaccess. Any help is very much appreciated. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongpa9277 2019-03-14 05:42
    关注

    Just create .htaccess in the main domain (www.example.com/) and put below code.

    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
    RewriteRule ^ /%1 [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥30 itest不允许查看成绩怎么办
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏