.htaccess重写301规则不起作用
我在简化我的URL的过程中,遇到了一个关于在htaccess文件中使用重写的问题 搜索引擎目前以以下格式列出我的页面.htaccess重写301规则不起作用,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我在简化我的URL的过程中,遇到了一个关于在htaccess文件中使用重写的问题 搜索引擎目前以以下格式列出我的页面 www.example.com/x/x/article\u a/1159/ 当前由位于/x/x目录中的以下htaccess文件重写 RewriteRule walk_a/(.*)/$ /x/x/article_a.php?id=$1 多年来,这种方法一直运作良好 我想将URL简化为 www.example.com/article-1159-introduction 我在根目录中
www.example.com/x/x/article\u a/1159/
当前由位于/x/x目录中的以下htaccess文件重写
RewriteRule walk_a/(.*)/$ /x/x/article_a.php?id=$1
多年来,这种方法一直运作良好
我想将URL简化为
www.example.com/article-1159-introduction
我在根目录中尝试了以下重定向
RewriteRule ^x/x/article_a/(.*)/$ http://www.example.com/article-$1-introduction [R=301,NC,L]
RewriteRule ^article-(.*)-introduction$ /x/x/article_a.php?id=$1
301重写似乎没有效果,尽管第二个重写命令工作正常
我做错了什么 在
/x/x/.htaccess
目录中使用以下规则:
RewriteEngine On
RewriteRule ^article_a/(.*)/$ /article-$1-introduction [R=301,NC,L,NE]
RewriteEngine On
RewriteRule ^article-(.+)-introduction$ /x/x/article_a.php?id=$1 [L,QSA]
那么在root.htaccess中有以下规则:
RewriteEngine On
RewriteRule ^article_a/(.*)/$ /article-$1-introduction [R=301,NC,L,NE]
RewriteEngine On
RewriteRule ^article-(.+)-introduction$ /x/x/article_a.php?id=$1 [L,QSA]
在
/x/x/.htaccess
目录内使用以下规则:
RewriteEngine On
RewriteRule ^article_a/(.*)/$ /article-$1-introduction [R=301,NC,L,NE]
RewriteEngine On
RewriteRule ^article-(.+)-introduction$ /x/x/article_a.php?id=$1 [L,QSA]
那么在root.htaccess中有以下规则:
RewriteEngine On
RewriteRule ^article_a/(.*)/$ /article-$1-introduction [R=301,NC,L,NE]
RewriteEngine On
RewriteRule ^article-(.+)-introduction$ /x/x/article_a.php?id=$1 [L,QSA]
谢谢你的答复。我有两个htacess文件,一个在/x/x中,一个在rootIs
文章中,php
位于/x/code>中?是的,我就是这么想的。您是否尝试过我更新的答案(需要在这两个.htaccess中都有一个规则)只需将其设置为treid即可!非常感谢你的帮助。我现在必须试着去理解它为什么有效!如果我有多条重写规则,我是否需要删除括号中的L标记?谢谢您的回复。我有两个htacess文件,一个在/x/x中,一个在rootIs文章中,php
位于/x/code>中?是的,我就是这么想的。您是否尝试过我更新的答案(需要在这两个.htaccess中都有一个规则)只需将其设置为treid即可!非常感谢你的帮助。我现在必须试着去理解它为什么有效!如果我有多个重写规则,我是否需要删除括号中的L标记?