Question about htaccess

  • gohostme
  • Newbie
  • Newbie
  • gohostme
  • Posts: 6

Post 3+ Months Ago

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!
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

http://httpd.apache.org/docs/mod/mod_rewrite.html
go check this url for a description.
hope it helps.
  • gohostme
  • Newbie
  • Newbie
  • gohostme
  • Posts: 6

Post 3+ Months Ago

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
  • webmasterbrain
  • Posts: 51

Post 3+ Months Ago

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
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

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.
  • gohostme
  • Newbie
  • Newbie
  • gohostme
  • Posts: 6

Post 3+ Months Ago

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
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

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
  • gohostme
  • Posts: 6

Post 3+ Months Ago

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
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

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
  • gohostme
  • Posts: 6

Post 3+ Months Ago

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 95 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.