Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to redirect all urls from the host to I've explored all the options - Apache redirect, rewriterule directives. I want the redirects to happen to the same target url - which is - regardless of what the original url was (e.g. All the examples that claim to be able to do this, actually don't, in practice (atleast on my Apache installation). The a.html is carried forward to the redirected host - which is not what is desired.

Any ideas?

share|improve this question
can you possible tell if you have <Directory /> in your httpd.conf or inside your VirtualHost with AllowOverride and what is it set to ? it may be the cause why your mod_rewrite inst working. – Prix Aug 22 '10 at 7:55
NameVirtualHost *:80
<VirtualHost *:80>
  RedirectMatch .*$

See for details.

share|improve this answer
RewriteEngine On
RewriteRule ^(.*)$ [R,L]

Does that work?

share|improve this answer
Thanks, but it doesn't - in fact, this is the most common example I've come across. – talonx Aug 20 '10 at 7:51

I belive something like this would do the job

RewriteEngine on
RewriteCond %{HTTP_HOST} ^
rewriterule ^(.*)$$1 [R=301]
share|improve this answer
Thanks, but it doesn't. Am suspecting something with my Apache installation now. – talonx Aug 20 '10 at 7:55
@talonx then you don't have mod_rewrite enable at least. – Prix Aug 20 '10 at 7:57
Hmm...I checked - seems to be enabled. – talonx Aug 20 '10 at 8:37
what "seems to be enabled" means ? i am sorry but it is "yes, it is enabled" or "no, it is not". Have you looked into the httpd.conf file for the module load entry for mod_rewrite, have you check for the .ht entry aswell ? Can you update your answer with more information like how are you using the rules above, what and where the file is located etc ? – Prix Aug 20 '10 at 9:14
@Prix - sorry, my bad. It is enabled. The LoadModule entry is present, and so is the .htaccess entry (I assume that's what you meant). Thanks for the help. – talonx Aug 20 '10 at 10:01

Your Answer


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.