RewriteRule 或 301 重定向
我从我的朋友那里继承了一个用 ColdFusion 完成的网站。所有的网址都是这样的: index.cfm
, filename.cfm?xid=MN
我做了这样的简单规则:
RewriteRule filename.cfm filename.php
它为顶级文件完成了工作。
但现在我正在处理二级文件,它们有这样的链接: filename.cfm?id=wanted&xid=MN
假设打开另一个页面,问题是当我写这个时:
RewriteRule filename.cfm?id=wanted&xid=MN folder/filename.php
它不起作用。我知道对于精明的开发人员来说这是一个愚蠢的问题,但我是新手,我需要帮助。请提出解决方案。非常感谢。
The pattern of those urls:
I have I need
/fileone.cfm?id=overview&xid=MN /folderone/overview.php
/fileone.cfm?id=wanted&xid=MN /folderone/wanted.php
/fileone.cfm?id=services&xid=MN /folderone/services.php
/filetwo.cfm?id=overview&xid=MN /folderwto/overview.php
/filetwo.cfm?id=wanted&xid=MN /folderwto/wanted.php
/filetwo.cfm?id=services&xid=MN /folderwto/services.php
等等....
I have inherited a website from my friend which was done in ColdFusion. All urls are like:index.cfm
, filename.cfm?xid=MN
I did simple rules like this:
RewriteRule filename.cfm filename.php
and it did the work for top level files.
But now I'm working on second level files and they have links like this: filename.cfm?id=wanted&xid=MN
wich suppose to open another page, the problem is when I write this:
RewriteRule filename.cfm?id=wanted&xid=MN folder/filename.php
it doesn't work. I know it's a stupid question for a savvy developer, but I'm a newbie and I need help. Please suggest a solution. This is very much appreciated.
The pattern of those urls:
I have I need
/fileone.cfm?id=overview&xid=MN /folderone/overview.php
/fileone.cfm?id=wanted&xid=MN /folderone/wanted.php
/fileone.cfm?id=services&xid=MN /folderone/services.php
/filetwo.cfm?id=overview&xid=MN /folderwto/overview.php
/filetwo.cfm?id=wanted&xid=MN /folderwto/wanted.php
/filetwo.cfm?id=services&xid=MN /folderwto/services.php
And so on....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下内容添加到站点根目录中的
.htaccess
文件中。这适用于您上面请求的所有重写,例如当用户请求
/fileone.cfm?id=overview&xid=MN
时,他们将获得/folderone/overview.php< /代码>。
如果您想对用户进行 301 重定向,请将最后一条规则更改为
Add the following to the
.htaccess
file in the root directory of your site.This will work for all of the rewrites you requested above e.g. when the user asks for
/fileone.cfm?id=overview&xid=MN
, they will get/folderone/overview.php
.If you want to 301 redirect the users change the last rule to