[英]Setting the HTACCESS file to redirect all .cfm requests to index.php
I have a .htaccess rewrite rule that I wrote, that is supposed to take any requests that container index.cfm and redirect them to the index.php. 我写了一个.htaccess重写规则,该规则应该接收容器index.cfm的所有请求,并将它们重定向到index.php。
http://testsite.com/index.cfm/a/catalog.prodShow/vid/42110/catid/154 http://testsite.com/index.cfm/a/catalog.prodShow/vid/42110/catid/154
However, it is not redirecting this properly. 但是,它没有正确重定向。 If I just put in index.cfm (no rest of the url) it works fine, however, the moment the /a/... is added to it, it takes me to the 404 page.
如果我只是放入index.cfm(没有其余的URL),则可以正常工作,但是,在将/ a / ...添加到它的那一刻,它将带我进入404页。
How do I adjust my rule so that it works properly for ANY url that has index.cfm anywhere in it? 如何调整规则,以使其对于其中任何位置具有index.cfm的任何URL正常工作?
Here is my rule: 这是我的规则:
RewriteRule ^index.cfm$ /index.php [L,NC,R] RewriteRule ^ index.cfm $ /index.php [L,NC,R]
Thanks. 谢谢。
In your RewriteRule, the ^
and the $
indicate the start and the end of the line. 在您的RewriteRule中,
^
和$
指示行的开始和结束。 If you wish to match any index.cfm (like /index.cfm/a/...
or /sub1/sub2/index.cfm/...
) you can try: 如果您希望匹配任何index.cfm(例如
/index.cfm/a/...
或/sub1/sub2/index.cfm/...
),则可以尝试:
RewriteRule ^(.*index.cfm.*)$ /index.php?original_url=$1 [L,NC]
I added the original url as a parameter because you might need it to process the request and I removed the R
flag to avoid loops. 我添加了原始url作为参数,因为您可能需要它来处理请求,并且我删除了
R
标志以避免循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.