【发布时间】:2014-04-23 01:31:16
【问题描述】:
我将网站的 /news/ 部分移至 /about/news/。现在我需要将旧链接重定向到移动的页面。我尝试在 .htaccess 中使用 RewriteRule,但它似乎不起作用:
RewriteEngine on
RewriteBase /
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php
RewriteRule ^$ inner.php?pathstring=/main/
RewriteRule ^(.+str=.*)$ inner.php?path=$1 [L]
RewriteRule ^([^\.]+)$ inner.php?path=$1 [QSA]
RewriteRule ^/news/(.*)$ about/news/$1 [R,L]
我在这里发布了我的整个 .htacces,因为它是由现在无法使用的其他人编写的,并且作为 php 中的菜鸟,我担心它可能会影响我以某种方式重定向的尝试。
【问题讨论】:
-
将它移到之前您的其他 RewriteRules。您的第三个匹配任何没有
.的内容(任何不是.的字符匹配 1 到无限次)。 -
谢谢我做到了,但重定向仍然没有发生。也许我的正则表达式有错误?我得到的只是 404。
标签: php .htaccess mod-rewrite