Regex 301用“重定向”/&引用;而不是",/"E;”这些可以合并吗?

Regex 301用“重定向”/&引用;而不是",/"E;”这些可以合并吗?,regex,.htaccess,mod-rewrite,redirect,Regex,.htaccess,Mod Rewrite,Redirect,我对301规则很熟悉,我想知道是否有可能在结尾处合并带“/”和不带“/”的URL 下面是我的htaccess的一个示例 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rewrite

我对301规则很熟悉,我想知道是否有可能在结尾处合并带“/”和不带“/”的URL

下面是我的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]
</IfModule>
# END WordPress

#Redirects
Redirect 301 /old/old-url/ https://www.newdomain.com/newurl/
Redirect 301 /old/old-url  https://www.newdomain.com/newurl/
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#重定向
重定向301/旧/旧url/https://www.newdomain.com/newurl/
重定向301/旧/旧urlhttps://www.newdomain.com/newurl/

有没有办法将这两个重定向合并为一个重定向?或者每一个301是否需要同时使用“/”和“否”/“

是的,您可以将其组合起来,但不要将
重定向
与其他
修改重写
规则一起使用:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Redirects
RewriteRule ^old/old-url(/.*)?$ https://www.newdomain.com/newurl/ [L,NC,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
#重定向
重写规则^old/旧url(/.*)?$https://www.newdomain.com/newurl/ [L,NC,R=301]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

(/.*)
最后将匹配可选的尾随斜杠。

是的,您可以将其组合,但不要将
重定向
与其他
修改
规则一起使用:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Redirects
RewriteRule ^old/old-url(/.*)?$ https://www.newdomain.com/newurl/ [L,NC,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
#重定向
重写规则^old/旧url(/.*)?$https://www.newdomain.com/newurl/ [L,NC,R=301]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

(/.*)
最后将匹配可选的尾随斜杠。

在我为尾随斜杠添加(/?*)而不是/>$之前,我无法使重写规则起作用-任何可能导致问题的原因?这意味着您的URL在
/old/old URL/
之后还有其他组件。见最新答案谢谢Anubhava,你帮了大忙!在我为尾部斜杠添加(/?*)而不是/>$之前,我无法使该重写规则起作用-任何可能导致问题的原因?这意味着您的URL在
/old/old URL/
之后还有其他组件。见最新答案谢谢Anubhava,你帮了大忙!