Question about htaccess

  • gohostme
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 11, 2004
  • Posts: 6
  • Status: Offline

Post June 11th, 2004, 1:00 am

hello all,

I'm new here and already got question I can't find an answer to :)

I need to write a rewrite rule for:
http://domain.com to rewrite to http://www.domain.com

Anyone familiar with Apaches rewrite rules? please help if it's not hard :)

Thanks in advance!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 11th, 2004, 1:00 am

  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post June 11th, 2004, 1:28 am

http://httpd.apache.org/docs/mod/mod_rewrite.html
go check this url for a description.
hope it helps.
Watch me grow
  • gohostme
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 11, 2004
  • Posts: 6
  • Status: Offline

Post June 11th, 2004, 2:10 am

Yeah all day was reading this manual and trying to understand,
but no luck :(
Maybe someone did it for his/her self?
maybe someone can share it? :)

thanks
  • webmasterbrain
  • Beginner
  • Beginner
  • No Avatar
  • Joined: May 04, 2004
  • Posts: 51
  • Status: Offline

Post June 13th, 2004, 6:30 pm

gohostme wrote:
hello all,

I'm new here and already got question I can't find an answer to :)

I need to write a rewrite rule for:
http://domain.com to rewrite to http://www.domain.com

Anyone familiar with Apaches rewrite rules? please help if it's not hard :)

Thanks in advance!


You can't to do this with mod_rewrite, you need to add a DNS record for http://domain.com (what type will depend on your setup)

Ask your host
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post June 13th, 2004, 6:53 pm

webmasterbrain is correct. this is a dns issue, and your host is the only one that can help to
point the records correctly for you.
UNFLUX.FOTO
  • gohostme
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 11, 2004
  • Posts: 6
  • Status: Offline

Post June 13th, 2004, 11:27 pm

nonsense!
I've done this before with some help, but now can't remember how :)
It was 3 lines in my .htaccess and all worked just fine!

I'm good in PHP not in apache's rules, but I'll make it to work!
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Joined: Jul 28, 2003
  • Posts: 774
  • Loc: Brisbane, Australia
  • Status: Offline

Post June 14th, 2004, 7:58 am

there may be something in your control panel you can change, or maybe even something you can put in your htaccess.

But a rewrite rule is not the answer. A rewrite rule will only rewrite the stuff after the first / in a URL, not stuff that's part of the domain.
  • gohostme
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 11, 2004
  • Posts: 6
  • Status: Offline

Post June 14th, 2004, 8:03 am

Hrm, maybe I explained incorrectly :/
Let's see: microsoft.com and http://www.microsoft.com
when you enter without www. it redirects to http://www.microsoft.com
and I'v done it before, but can't google it now :)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post June 14th, 2004, 11:29 am

I know what gohostme means, and I'm guessing that both domain.com and http://www.domain.com already point to a website (the same site).

The reason you may want to redirect is so that all people (and search engines) are seeing the same URLs, and you're not leaking any of that precious PageRank :)

Try this :)

Code: [ Select ]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
  1. RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
  2. RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Obviously change domain with your actual domain name.
  • gohostme
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 11, 2004
  • Posts: 6
  • Status: Offline

Post June 14th, 2004, 11:42 pm

Thanks man!
I should explain myself more clearly next time :)

Thanks again!

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 257 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.