Apache Rewrite rules anyone
Discussion
Hi all,
I have not written any rules for a while and I'm stuck.
Basically I want users who to try to visit http://mydomainblahblahblah.com
to see http://www.mydomainblahblahblah.com
so basically to insure the www is added if missing.
I'm doing this via a .htaccess file.
I've looked in the manual which gives this example:
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
now I'm making an error somewhere as it does not work.
any help appreciated.
I have not written any rules for a while and I'm stuck.
Basically I want users who to try to visit http://mydomainblahblahblah.com
to see http://www.mydomainblahblahblah.com
so basically to insure the www is added if missing.
I'm doing this via a .htaccess file.
I've looked in the manual which gives this example:
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
now I'm making an error somewhere as it does not work.
any help appreciated.
mod rewrite is enabled.
.htaccess files work fine.
I've had this problem before and solved it
(Cannot remember what I did though ...it was two years ago)
can you/someone post what it should look like ?
use www.blahsomedomain.com
could it be something simple like spaces ?
thx
.htaccess files work fine.
I've had this problem before and solved it
(Cannot remember what I did though ...it was two years ago)
can you/someone post what it should look like ?
use www.blahsomedomain.com
could it be something simple like spaces ?
thx
thanks guys - mod rewrite is working
beacuse re-write rules are working (some software on the server uses them).
Basically my current webhost has setup the servername as somedomainname.com
and then used an alias for www.somedomainname.com.
so by default the website uses the domain name without the www. This is problematic because if a user trys accessing say
www.somedomainname.com/cars (not the missing trailing slash) the server sends them to http://somedomainname.com/cars/ . Which can throw javascript /code errors sometimes.
(which is happening now).
If you add the trailing slash at the end , the site displays correctly.
Thats why I'm trying to use Apache rewrite rules to send any requests for somedomainname.com to www.somedomainname.com
*Note: The domain name mentioned is used as an example only. No TLDs were harmed during posting.
:-)
beacuse re-write rules are working (some software on the server uses them).
Basically my current webhost has setup the servername as somedomainname.com
and then used an alias for www.somedomainname.com.
so by default the website uses the domain name without the www. This is problematic because if a user trys accessing say
www.somedomainname.com/cars (not the missing trailing slash) the server sends them to http://somedomainname.com/cars/ . Which can throw javascript /code errors sometimes.
(which is happening now).
If you add the trailing slash at the end , the site displays correctly.
Thats why I'm trying to use Apache rewrite rules to send any requests for somedomainname.com to www.somedomainname.com
*Note: The domain name mentioned is used as an example only. No TLDs were harmed during posting.
:-)
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


