Apache 2.2.9 mod_rewrite

frog9394

Verified User
Joined
Jun 27, 2008
Messages
26
Hello, Everybody. I have a problem about mod_write in my Custom_builded apache 2.2.9.

I just want to add a global rewrite rule to force domain.com -> www.domain.com. The code as below.

# Forcing no sub domain to WWW. eg: site.com -> www.site.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([-a-z0-9_]+\.[-a-z0-9_]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

but even I've try to add in /etc/httpd/conf/extra/http-default.conf or http-vhost.conf or httpd.conf. It doesn't work.

But when I put it in .htaccess file in one of our site. It works perfectly. So I think mod_rewrite is working properly. Any one can tell me where can I put the code and it will work globally? Thanks a lot! :confused:
 
Back
Top