重写具有类似模式的规则无效。

huangapple go评论86阅读模式
英文:

Rewrite rule with similar pattern doesn't work

问题

RewriteRule ^tours/$ /tours/page/1/ [R=301,NC,L]

我也想重写该路径中的特定页面,因为某些页面已被删除,Google Search Console警告404通知:

RewriteRule ^tours/live-in-las-vegas-2020/$ /tours/live-in-las-vegas-2019/ [R=301,NC,L]

我无法使第二个重写规则重定向到正确的页面。这绝对是正确的URL,我尝试删除了“L”,改变了行的顺序,并删除了“tours”路径。

我在文件的顶部有这个:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^(.
).rwdb.info$ [NC]
RewriteRule ^(.*)$ https://www.rwdb.info/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [NE,L,R=301]

Options All -Indexes
Options +FollowSymLinks

我还有这个规则来美化我的PHP网址:

RewriteRule ^tours/page/([^/])/$ /index.php?type=tour&page=$1 [L]
RewriteRule ^tours/([^/]
)/$ /index.php?type=tour-detail&seo_link=$1 [L]

我漏掉了什么?

英文:

I have a rewrite rule in my .htaccess file to redirect a path to a different path:

RewriteRule ^tours/$    /tours/page/1/ [R=301,NC,L]

I also want to rewrite specific pages in that path as some pages are removed and Google Search Console alerts a 404 notification:

RewriteRule ^tours/live-in-las-vegas-2020/$                 /tours/live-in-las-vegas-2019/ [R=301,NC,L]

I cannot get the second one to redirect to the correct page. It's definitely the correct url, I tried to remove the "L", change sequence of the lines and removed the "tours" path.

I've got this at the top of my file

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^(.*)\.rwdb.info$ [NC]
RewriteRule ^(.*)$ https://www.rwdb.info/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [NE,L,R=301]

Options All -Indexes
Options +FollowSymLinks

And I've got this one to prettify my URLs from PHP

RewriteRule ^tours/page/([^/]*)/$    /index.php?type=tour&page=$1 [L]
RewriteRule ^tours/([^/]*)/$         /index.php?type=tour-detail&seo_link=$1 [L]

What am I missing?

答案1

得分: 1

抱歉,我找到了解决方案,我试了很长时间,发帖后才找到了解决方法。这是一个顺序问题。具体的重定向应放在美化模式之上。

英文:

I found the resolution, apologies I was trying for so long and after posting I found the solution. It's a matter of sequence. The specific redirects should be placed above the prettify pattern.

huangapple
  • 本文由 发表于 2023年6月5日 21:34:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76406967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定