Pregunta

I'm currently redirecting all requests to my Apache server from olddomain.com to newdomain.com -- it works fine but I actually need just ONE file to still be loaded as if it's at olddomain.com.

Here's what the important bit looks like now:

<VirtualHost *:80>
ServerName olddomain.com
ServerAlias olddomain.com

Redirect / http://newdomain.com/
</VirtualHost>

I loved this simple Redirect / http://newdomain.com solution because it does exactly what I want and is so simple even I can understand it! BUT how do I make an exception so that when someone/something goes to http://olddomain.com/excludedfile.php, it loads to the expected domain name? The solutions I've found so far seem to be for mod_rewrite setups. If mod_rewrite is what's required I guess I can live with it but I'd rather not...

Why I need this: I just submitted my app to Apple and decided at the last minute that I needed to change the domain name, which breaks one feature of the app because it's relying explicitly on seeing the old domain name -- it doesn't see it anymore because of the changes made to my virtual hosts file.

¿Fue útil?

Solución

You will need to use RedirectMatch for the regex capabilities:

RedirectMatch 301 ^((?!.*?excludedfile\.php).*)$ http://newdomain.com$1

This change will require you to restart the Apache.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top