Newbie Trying to force www

New to mod_rewrite? This is a good place to start.

Newbie Trying to force www

Postby vengeance » Wed Aug 12, 2009 5:26 pm

Hi, I am attempting to use mod_rewrite in httpd.conf to force a number of things IE: https, state, and www. I have https and state working but can not seem to get www going . What am I missing. Thanks in advance

Code: Select all
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/mydir/welcome.do
RewriteCond %{REQUEST_URI} ^/ks*
RewriteRule (.*) https://www.example.com/mydir/welcome.do?state=KS
RewriteCond %{REQUEST_URI} https://example.com
RewriteRule (.*) https://www.example.com/mydir/welcome.do
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
vengeance
 
Posts: 1
Joined: Wed Aug 12, 2009 5:08 pm

Postby richardk » Fri Aug 14, 2009 1:17 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) [NC]
RewriteRule .* - [F,L]

# Force www
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^/(.*)$ https://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule .* https://www.example.com/mydir/welcome.do [QSA,L]

RewriteRule ^/ks(/.*)?$ https://www.example.com/mydir/welcome.do?state=KS [QSA,L]

RewriteRule ^$ https://www.example.com/mydir/welcome.do [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 33 guests

cron