I simply transformed url schemes, so example.com/ugly has become example.com/nice
example.com/ugly still handles the request - .htaccess has this rule:
RewriteRule ^nice$ example.com/ugly [PT,L,QSA]
That much works.
Now Let me redirect example.com/ugly to example.com/nice, but nonetheless have example.com/ugly handle the request. Something similar to this:
- Redirect example.com/ugly to example.com/nice (301)
- Internally redirect example.com/nice to example.com/ugly, without letting the consumer know, and without repeating step one
Simple methods for carrying this out result in looping obviously. It is possible to method of doing this with .htaccess? Otherwise, can there be one other way?
The easiest way I understand of is applying PHP within the target file. Here's roughly what you would add:
if($_SERVER['REQUEST_URI'] == '/index.php') header("Location: http://".$_SERVER['HTTP_HOST']."/");
Clearly you have to then add other variables inside to deal with whatever demands, but that is the fundamental idea.