I would like to redirect www.example.it
to www.example.com/index-it.php
The website is just a one-page site.
I would like that to happen transparently, in the sense that www.example.it will be still displayed on the address bar after the redirect.
I have tried this but it generates an Internal Server Error.
<VirtualHost *:80>
ServerName www.example.it
RewriteEngine on
RewriteRule ^/.*$ http://www..com/index-it.php [P,L]
</VirtualHost>
This would work instead, but it doesn't provide a transparent redirect:
<VirtualHost *:80>
ServerName www.example.it
RewriteEngine on
#RewriteRule ^/.*$ http://www.example.com/index-it.php [P,L]
Redirect 301 / http://www.example.com/index-it.php
</VirtualHost>
Any idea, please? Thanks.
I suggest that you don't actually want to redirect, because "redirect" actually means "tell the browser to request this other page instead."
Also, I'm betting you don't actually want to redirect all requests, because if your browser URL bar shows
www.example.it
and the page it has loaded has a reference to/logo.png
, the browser will requesthttp://www.example.it/logo.png
and it will be surprised to get the output ofwww.example.com/index-it.php
in response.Because you're using the
[P]
flag, the approach you're actually taking is reverse proxing all requests towww.example.it
towww.example.com
, and before proxying, internally rewrite some subset of index requests onwww.example.it
to/index-it.php
. The When Not To Use Rewrite page lists "proxying" as one of its times not to usemod_rewrite
.mod_proxy
by itself wil help you with the proxying;mod_rewrite
's documentation actually suggests preferringmod_proxy
directives over theP
flag.Read
mod_proxy
's warning about being sure your server is secure before you turn it on. The index-file juggling may be a reasonable use ofmod_rewrite
, but it doesn't require use of theP
flag.Just a silly problem: mod_proxy wasn't enabled