htaccess的重写规则不工作与使用.CFM结尾的URL [英] htaccess rewrite rules are not working with urls that end with .cfm
问题描述
我在努力解决我的所有的URL是用较短的301重定向。我有解决几乎所有的人,但有一个URL,它是结束与.CFM不会改写。
FROM:http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page。 CFM
TO:http://www.mydomain.com/story/resources/health/page/168/page.html
如果我修改 /page.cfm
到 /page.html
然后重写会工作。
下面是重写规则适用于我的其他网址
重写规则^index.cfm/catlink/([a-zA-Z0-9/-]+)([/])pagelink/([a-zA-Z0-9/-]+)([/])sublink/([a-zA-Z0-9/-]+)([/])art/([a-zA-Z0-9/-]+)(.*)$
?HTTP://localhost/index.cfm页=移动和放大器;猫= $ 3及subcat = $ 5和文章= $ 7和故事= $ 8 R = 301]
为什么当URL以.html结尾而不是在它与.CFM结束它的工作原理?我究竟做错了什么?
这是流通环节,将无法工作:
http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page.cfm
如果我手动更改它的结束为.html,我可以得到它的工作:
<$p$p><$c$c>http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page.html
问题是,Apache正在其传递到Tomcat之前的Apache着眼于的.htaccess。为了验证这一点,将你的重写规则到你的虚拟主机。如果他们的工作,那么这就是问题了。
I'm working on fixing all my URL's to be shorter with 301 redirects. I have fix almost all of them, however there is a url that is ending with .cfm that will not rewrite.
FROM: http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page.cfm
TO: http://www.mydomain.com/story/resources/health/page/168/page.html
If I change /page.cfm
to /page.html
then the rewrite will work.
Here is the rewrite rule that works for my other urls
RewriteRule ^index.cfm/catlink/([a-zA-Z0-9/-]+)([/])pagelink/([a-zA-Z0-9/-]+)([/])sublink/([a-zA-Z0-9/-]+)([/])art/([a-zA-Z0-9/-]+)(.*)$
http://localhost/index.cfm?page=moved&cat=$3&subcat=$5&article=$7&story=$8 [R=301]
Why does it work when the URL ends with .html but not when it ends with .cfm? What am I doing wrong?
This is current link and will not work:
http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page.cfm
If I manually change the end of it to .html, I can get it to work:
http://www.mydomain.com/index.cfm/catlink/17/pagelink/7/sublink/34/art/41/rec/1/page.html
The issue is that Apache httpd is passing it off to Tomcat before Apache looks at the .htaccess. To test this, move your rewrite rules into your vhost. If they work, then that's what the problem was.
这篇关于htaccess的重写规则不工作与使用.CFM结尾的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!