0

I have a file called "abc.html". In the past this was called "abc.cfm". From an outsider's point of view I want it to look like abc.cfm still exists (and it should be the content of abc.html).

Currently I have this in my htaccess: RewriteRule ^abc.cfm$ abc.html [L]

This works perfectly. Whenever you go to abc.cfm, it shows the content of abc.html, withour redirects (from the user's POV).

The problem is that I can also reach abc.html now and that's duplicate content. I can solve this by adding a canonical saying the abc.cfm is original URL. I just wondered if it's possible to have a 301 from the html to the cfm file (which internally calls for the html again). Without getting into an infinite loop of course :-)

I am also open for other solutions. (but I can't change the links pointing to the abc.cfm file and I don't want a 301 redirect to the abc.html file)

Rick
  • 806
  • 7
  • 15
  • I don't think so. The requested URL ends up being the same resource URL and it will go into a loop impossible to control. Check this [answer](http://stackoverflow.com/questions/13832468/how-to-stop-htaccess-loop/13832827#13832827) – Felipe Alameda A Dec 12 '12 at 06:29

1 Answers1

0
Redirect 301 /abc.html /abc.cfm

Put this line before your RewriteEngine on directive.

If you want to do it in mod_rewrite, you could use the following instead:

RewriteRule ^abc.html$ abc.cfm [R=301, L]

This will force the user's browser to only be able to request the .cfm page, while internally the server knows to grab the content from the .html page. This rule needs to be before the internal rewrite rule you have listed above, but after the RewriteEngine on directive.

Wige
  • 3,788
  • 8
  • 37
  • 58
  • The top solution doesn't seem to do anything. both pages are still reachable. The second solution I tried that already actually, but it got me in an infinite loop: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. – Rick Dec 13 '12 at 04:40