301 RedirectMatch - 发行 [英] 301 RedirectMatch - Issue

查看:281
本文介绍了301 RedirectMatch - 发行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我张贴一个问题,在这里我得到了一个答案,但现在我已经确定了一个问题,code。

I posted a question here which I got an answer for, but now I've identified an issue with the code.

原题:

301 RedirectMatch - 许多网址

RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)\.html$ /$1-$2-in-$3.html [R=301,L]

在与网址上修复了所有的问题,我注意到了我的正常网址有问题。例如,domain.com/careers-jobs-music-degree.html正在变成domain.com/careers-jobs-in-music-degree.html - 在IN被添加到没有其他网址在URL中的音乐类。有没有什么办法prevent呢?

While the above fixed all the issues with the URLs, I noticed my normal URLs are having issues. Example, domain.com/careers-jobs-music-degree.html is turning into domain.com/careers-jobs-in-music-degree.html - the 'in' is being added to other URLs that don't have 'music-classes' in the URL. Is there any way to prevent this?

谢谢!

推荐答案

您可以试试这种方式使真实的URL应该不会受到影响的规则。

You can try the rules this way so real URLs shouldn't be affected.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)\.html$ /$1-$2-in-$3.html [R=301,L]

这篇关于301 RedirectMatch - 发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆