SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    how to do no-www to www to all Inside page of a site?

    i used the following code in .hactess. but it doesn't work.
    Code:
    Options +FollowSymLinks 
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    when i access
    Code:
     http://example.com/1.html
    it doesn't redirect to
    HTML Code:
    http://www.example.com/1.html
    it redirect to http://example.com

    Code:
    http://example.com/news.html
    to
    Code:
    http://www.example.com/news.html
    ,it redirect to http://example.com

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Try this:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Ralph,

    Thanks. That's my preferred version of the same but RED's code should work so there is something else going on which he is not showing (perhaps a Redirect / http://www.example.com).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Off Topic:

    Quote Originally Posted by dklynn View Post
    That's my preferred version ...
    Heh heh, I figured I would keep you happy if I quoted your own code.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)


    Unfortunately, you're not built right to keep me happy!



    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Off Topic:

    Quote Originally Posted by dklynn View Post
    Unfortunately, you're not built right to keep me happy!
    Now you're sounding like my wife.

    PS: I learned at university that a sure way to get good marks was to quote my lecturers in my essays and agree with their views and theories.

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Ralph,

    I think I shouldn't comment about your wife's opinion of you - at least what she's telling you!

    As for the profs, wasn't it more fun to quote an authority with an opposing view and watch the tirade?

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Off Topic:

    Quote Originally Posted by dklynn View Post
    As for the profs, wasn't it more fun to quote an authority with an opposing view and watch the tirade?
    Nah, I couldn't be bothered with the confrontation. It was easier to keep them happy and get good grades.

    (I didn't enjoy uni much, and just wanted to get it over with. The few times I did stir up trouble, it wasn't very fun. I ended by doing a teaching course, and I tore apart some of their ridiculous teaching theories, and they threatened to fail me. Because I just wanted the piece of silly paper, I kept my mouth shut after that.)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •