Solved A question About RewriteEngine

Hi

I add in httpd.conf (apache24)

Code:
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/apache24/data/www.example.com"
    ServerName www.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    ErrorDocument 400 /index.html
    ErrorDocument 401 /index.html
    ErrorDocument 402 /index.html
    ErrorDocument 403 /index.html
    ErrorDocument 404 /index.html
    ErrorDocument 500 /index.html
</VirtualHost>

My problem in

Code:
    RewriteCond %{HTTP_HOST} !^www.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

when I open the site

http://example.com

be transformative to

http://www.example.com//

I need remove (//) :( and make it normal like

http://www.example.com
or
http://www.example.com/
 
Not tested but this should probably do it:
Code:
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]

But what about something simpler?
Code:
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/apache24/data/www.example.com"
    ServerName www.example.com

    ErrorDocument 400 /index.html
    ErrorDocument 401 /index.html
    ErrorDocument 402 /index.html
    ErrorDocument 403 /index.html
    ErrorDocument 404 /index.html
    ErrorDocument 500 /index.html
</VirtualHost>
<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / http://www.example.com/
</VirtualHost>
 
Back
Top