Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Redirecting from no-www to www
Old 08-14-2008, 09:38 PM Redirecting from no-www to www
Skilled Talker

Posts: 71
Trades: 0
As I understand it, it is generally good practice to make it so that a visitor who comes to domain.com/some/page.html is automatically redirected to www.domain.com/some/page.html. In addition to the general reasons, I have the additional reason that the drupal part of my site has a number of issues when switiching between www and no-www.

I contacted my hosting company (after having little success finding a good tutorial) and, after trying a number of modifications to the .htaccess file that just messed things up, one the most recent responce has suggested that I might want to see if this is a Drupal problem.

Does anyone know how I can make the redirection work or know of a good guide?

Thanks!
zephyrcat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-15-2008, 10:09 AM Re: Redirecting from no-www to www
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Drupal does its own URL rewriting, because all of its URLs are dynamic, and don't look very good in the browser. Drupal's rewriting makes the page-names more friendly to users and search engines both.

What you are referring to is domain name canonicalization, which is also a form of URL rewriting, and normally (as you have figured out) is done via the .htaccess file.

This is how I do it in .htaccess:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
If that causes a conflict with Drupal's rewriting, I'm not sure what to do.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-15-2008, 11:45 AM Re: Redirecting from no-www to www
Skilled Talker

Posts: 71
Trades: 0
Thanks! I don't dare try it right now, since my website is getting a bunch (relatively) of traffic :-), but I will try it later. Thanks!
zephyrcat is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 01:16 PM Re: Redirecting from no-www to www
Skilled Talker

Posts: 71
Trades: 0
Thanks! That worked perfectly.
zephyrcat is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 03:01 PM Re: Redirecting from no-www to www
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You're welcome
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-19-2008, 12:10 AM Re: Redirecting from no-www to www
Skilled Talker

Posts: 71
Trades: 0
Oops... I guess I was wrong...

I got it working for everything except the Drupal part. It might help if I was very specific. Here is exactly what I am hoping for:

When every anyone goes to any of the following:
http://linuxloop.com/lldrupal2
linuxloop.com/lldrupal2
http://www.linuxloop.com/lldrupal2
http://linuxloop.com/lldrupal2/
linuxloop.com/lldrupal2/
http://www.linuxloop.com/lldrupal2/
(Basically, anything with linuxloop.com/lldrupal2 as part of it, including sub-directories.)

It should redirect them to:
http://www.linuxloop.com/lldrupal2/ (followed by whatever sub-directory they are in)

Thanks!
zephyrcat is offline
Reply With Quote
View Public Profile
 
Old 08-19-2008, 01:49 PM Re: Redirecting from no-www to www
Skilled Talker

Posts: 71
Trades: 0
Sorry for the double post. I got a bit closer.

I found some stuff commented out in Drupal's .htaccess file that helps. The lines I have modified and uncommented are here:
Code:
RewriteCond %{HTTP_HOST} ^linuxloop\.com$ [NC]
RewriteRule ^(.*)$ http://www.linuxloop.com/lldrupal2/$1 [L,R=301]

RewriteBase /lldrupal2
Everything works now except http://linuxloop.com/lldrupal2 (without a trailing slash). That redirects to http://www.linuxloop.com/lldrupal2//...loop/lldrupal2 . Any ideas?

Thanks!
zephyrcat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Redirecting from no-www to www
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.80872 seconds with 12 queries