douyi3833 2013-11-15 11:25
浏览 19

too long

I want to redirect old pages (like "index.php/sdasdasd/sdasda/") to their new content. I'm using PHP to do this, as the data is stored in MySQL. The problem is that when the url starts with "index.php" it isn't redirected to the correct page. In the background it should call: "index.php?url=index.php/sdasdasd/sdasda/". How can I fix this in the .htaccess?

RewriteEngine on

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

RewriteRule ^(.*/)?\.svn/ - [F,L]
RewriteRule \.(gif|jpg|png|css|flv|js|swf|php)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+\.php)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(\.)
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} .*

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

If you have any other improvements to this code, then you're welcome to suggest changes.

  • 写回答

1条回答 默认 最新

  • douhuan1979 2013-11-15 11:31
    关注

    How can I fix this in the .htaccess?

    You have one condition that is duplicated:

    RewriteCond %{REQUEST_URI} !(\.)
    RewriteCond %{REQUEST_URI} !(\.)
    

    You can remove one of them.

    But in order to redirect requests to /index.php/something, you need to add this just below RewriteEngine on:

    RewriteCond %{THE_REQUEST} \ /index\.php
    RewriteRule ^index\.php(.*)$ /$1 [L,R=301]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制