dongrenshi0889 2016-09-02 08:52
浏览 56
已采纳

htaccess Symfony2将所有* .php页面(但app.php)重定向到app.php

I would like to modify my htaccess to :

  1. Redirect all *.php calls to app.php (SEO call to keep ranking from migration)
  2. Avoid redirection loop excluding app.php for rewrite rule above.

I ended up with this :

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !app\.php$
    RewriteRule ^(.*)\.php?$ /app.php/ [R=301,L]

   [...]

</IfModule>

But this produces a 404 on test url like http://example.com/sqdlkqjsdlsqk.php

What's wrong in here?

Regards,

  • 写回答

2条回答 默认 最新

  • dszsajhd237437 2016-09-02 08:54
    关注

    You should be using this rule without trailing slash after app.php:

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/app\.php$ [NC]
    RewriteRule ^(.+)\.php$ /app.php [R=301,L,NC,NE]
    

    Make sure to clear browser cache before testing this change.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据