ModRewrite weird redirect behavior on removing WWW
Posted
by vitto
on Stack Overflow
See other posts from Stack Overflow
or by vitto
Published on 2010-06-01T10:36:24Z
Indexed on
2010/06/01
10:53 UTC
Read the original article
Hit count: 256
Hi, I'm trying to use some rule on my project to remove www
from the beginning of the URL
but I've some problem.
my server structure is:
domain.com/beta_folder
domain.com/beta_folder/page+type
domain.com/beta_folder/page+type/content+name
domain.com/beta_folder/page+type/content+name/edit
domain.com/beta_folder/page+type/content+name/etc.
domain.com/beta_folder/.htaccess //here is where my htaccess is
beta_folder
is the site folder, and content+name
are content vars, created to retrieve pages from the database.
the site works perfect with this rules
RewriteEngine On
RewriteRule ^(page\+type/)([a-zA-Z0-9_+-]+)[/]?$ page_folder/page.php?varname=$2
My intention was to remove www
, so I've added this rule but it isn't effective
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com$1 [R=301,L]
RewriteRule ^(page\+type/)([a-zA-Z0-9_+-]+)[/]?$ page_folder/page.php?varname=$2
My problem starts if I digit www
in front of my domain name:
this works
http://domain.com/beta_folder/page+type/content+name
if i write
http://www.domain.com/beta_folder/page+type/content+name
the rewrite rule redirect me at
http://www.domain.compage+type/content+name
if i remove the www
rules, the problem still active
unfortunately, I can't make a public test for my domain
basically, if I write
http://www.domain.com/beta_folder
the rules sends me to
http://domain.com/
where I'm wrong?
© Stack Overflow or respective owner