URL重写不适用于一个URL #开始WordPress 重新启动发动机 重写基/ 重写规则^index\.php$-[L] 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写规则/index.php[L] 重写规则^foo$/bar[L,R=301] #结束WordPress

URL重写不适用于一个URL #开始WordPress 重新启动发动机 重写基/ 重写规则^index\.php$-[L] 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写规则/index.php[L] 重写规则^foo$/bar[L,R=301] #结束WordPress,wordpress,apache,.htaccess,mod-rewrite,url-rewriting,Wordpress,Apache,.htaccess,Mod Rewrite,Url Rewriting,当我打开www.example.com/foo时,这些行对wordpress起作用,但是重写规则^foo$/bar[L,R=301]没有重定向。你试过将特定规则放在重写基/规则的正下方吗?我认为其他规则已经在起作用,导致你上一条规则被忽略 重写规则的顺序在.htaccess中很重要。将.htaccess代码更改为: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRul

当我打开
www.example.com/foo
时,这些行对wordpress起作用,但是
重写规则^foo$/bar[L,R=301]
没有重定向。你试过将特定规则放在
重写基/
规则的正下方吗?我认为其他规则已经在起作用,导致你上一条规则被忽略

重写规则的顺序在.htaccess中很重要。将.htaccess代码更改为:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteRule ^foo$ /bar [L,R=301]

</IfModule>

# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^foo/?$/bar[L,R=301]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

这很有帮助。但是(很抱歉)
RewriteRule^foo/test$/bar[L,R=301]
没有重定向,我有一个名为“foo”的文件夹,但没有test。这很有帮助。但是(很抱歉)
RewriteRule^foo/test$/bar[L,R=301]
没有重定向,我有一个名为'foo'的文件夹,但没有测试。所以你有
RewriteRule^foo/test$/bar[L,R=301]
我可以知道这是否是你唯一的.htaccess权限以及你在浏览器中键入的URI吗?用它代替
RewriteRule^foo/?$/bar[L,R=301]
URL是
www.example.com/foo/test
您能告诉我您的系统上是否有其他.htaccess权限吗?如果没有,请复制/粘贴此请求的access.log和error.log代码段。此请求的日志中没有任何内容,因为wordress显示的是“未找到页面”。没有其他访问权限。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^foo/?$ /bar [L,R=301]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress