开发者

Redirecting all dynamic URLs from an old site to a single static url

We had an old coldfusion website a couple of years ago and I recently realized there are some old links still floating around causing 404 errors. I don't know what was on any of the pages and I just want to redirect them to a new static page. Our new site is a Joomla 1.5 site with SEF URLs turned on.

An old URL would look like this: http://www.example.com/content.cfm?id=2010 where the only difference between the URLs would be the number after id=. I want to redirect any URL that begins with content.cfm to a the static page http://www.example.com/oops-thats-an-old-page wh开发者_开发知识库ich lists some helpful links to find what they are looking for.

I am successfully accomplishing this with the following code in the .htaccess file:

RewriteCond %{QUERY_STRING} id=
RewriteRule (.*) http://www.example.com/$1? [R=301]
RewriteRule ^content\.cfm$ /oops-thats-an-old-page [R=301,L]

I'm new to rewriting URLs and I'm not sure this is the best way to do it. I am also concerned that it may brake non-sef joomla URLs that I am not aware of because they also have the id= in them.

Can I make the rewrite conditional on whether or not it begins with content.cfm?


The first rule will already be applied when the query contains id=. If you don’t want that but rather redirect only if /content.cfm with query containing id= was requested, try this rule:

RewriteCond %{QUERY_STRING} id=
RewriteRule ^content\.cfm$ /oops-thats-an-old-page? [R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜