Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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 request http://www.example.it/logo.png and it will be surprised to get the output of www.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 to www.example.it to www.example.com, and before proxying, internally rewrite some subset of index requests on www.example.it to /index-it.php. The When Not To Use Rewrite page lists "proxying" as one of its times not to use mod_rewrite. mod_proxy by itself wil help you with the proxying; mod_rewrite's documentation actually suggests preferring mod_proxy directives over the P 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 of mod_rewrite, but it doesn't require use of the P flag.

share|improve this answer
    
I think I am already using mod_proxy as I am using P as a flag. Please see here: httpd.apache.org/docs/current/rewrite/flags.html –  dan Dec 22 '12 at 9:56
1  
That leads to two more questions, then: Are you sure mod_proxy is enabled? And, why use the P flag over just using mod_proxy's directives, when the mod_rewrite documentation says, "Avoid using this flag and prefer those directives, whenever you can."? (You may have a good reason, I'm just not seeing it in your question.) –  pjmorse Dec 22 '12 at 12:01
    
Thanks a lot - that led to the solution –  dan Dec 22 '12 at 20:07
    
@dan Your problem is solved, but for others who may get here later via search I've edited my answer to include my favorite link for Server Fault. –  pjmorse Dec 31 '12 at 14:09
up vote 0 down vote accepted

Just a silly problem: mod_proxy wasn't enabled

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.