Non WWW / WWW 301 Problem

Discussion in 'Apache' started by sonicdark, Dec 4, 2006.

  1. #1
    On my personal site I use the following .htaccess file and it works, but now I'm using it for a business site (microtekusa.com)

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.microtekusa\.com [NC]
    RewriteRule ^(.*) http://www.microtekusa.com/$1 [L,R=301]
    </IfModule>

    But I'm trying to get one of our companies sites to do this as well, but dropping this in the public_html folder for our site has no success. When I create it and drop it in nothing changes, its as if nothing occurs. Am I doing something wrong, or is htaccess just not turned on in Apache? I'm in Marketing and its possible IT didn't enable this. Anything other than that that I could be overlooking?

    Thanks!
     
    sonicdark, Dec 4, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    er, what are you trying to do? It looks like...nothing! Looks like you're redirecting from www. to www. aka...no change.
     
    Nintendo, Dec 4, 2006 IP
  3. sonicdark

    sonicdark Peon

    Messages:
    95
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm trying to go from non www to www 301 redirected on all pages.
     
    sonicdark, Dec 4, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^microtekusa\.com [NC]
    RewriteRule ^(.*)$ http://www.microtekusa.com/$1 [R=301,L]

    Notice your RewriteCond line has the www. aka...says you must be at www.domain.com to work!
     
    Nintendo, Dec 4, 2006 IP
  5. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Are you sure they're on a Unix server and have mod_rewrite enabled?
     
    nicknick, Dec 5, 2006 IP
  6. sonicdark

    sonicdark Peon

    Messages:
    95
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Says we have:

    Server Type: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7e

    I am determining if mod rewrite is enabled as well as htaccess, but just wanted to make sure that would be the only other thing

    Thanks for the help
     
    sonicdark, Dec 5, 2006 IP
  7. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I think mod_rewrite is the only thing you need for your .htaccess file to work but Nintendo is much more experienced in this if he wants to chime in. Just make sure it's turned on. I had the same problem with a server hosted by another company. Once they turned it on the same rewrite rules you have worked just fine. Good luck.
     
    nicknick, Dec 5, 2006 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Try this test, with index.html being the filename of the real index file.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko\.html$ index.html [L]

    domain.com/wacko.html should show the index page if you got mod_rewrite.

    LOL! I've posted twice!! It's the avatar that makes it hard to notice who's making da post!!!!
     
    Nintendo, Dec 6, 2006 IP
  9. sonicdark

    sonicdark Peon

    Messages:
    95
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Yeah, nothing is coming up under wacko.html for that domain so it looks like I need to have mod_rewrite enabled. Thanks!
     
    sonicdark, Dec 6, 2006 IP
  10. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Didn't recognize you without the crown. :eek:
     
    nicknick, Dec 6, 2006 IP
  11. sonicdark

    sonicdark Peon

    Messages:
    95
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Here is what I got back from our IT guys:

    mod_rewrite is now enabled on Apache on both servers:

    http://support.microtek.com/test.phtml

    Does that look correct on the settings? I uploaded the .htaccess file again and still no change

    Thanks!
     
    sonicdark, Dec 8, 2006 IP
  12. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Try this code and see if it works. If not, post again and we'll try to figure something out.

    <IfModule mod_rewrite.c>
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.microtekusa\.com [NC]
    RewriteRule ^(.*) http://www.microtekusa.com/$1 [R=301,L]
    </IfModule>
     
    nicknick, Dec 8, 2006 IP
  13. sonicdark

    sonicdark Peon

    Messages:
    95
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Hmm, doesn't work

    On the link I posted above it supposedly has all our server settings

    Is something in there setup incorrectly or not turned on?
     
    sonicdark, Dec 8, 2006 IP
  14. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Things seem okay but there is no way to be sure that it's not turned off in the config file. You'll need to ask your server host if they enabled mod_rewrite rather than just installing it. It can be installed but turned off on the main configuration file which will keep it from working on the whole server.

    The code I gave you works on about 10 sites I have it on so it should work.

    Try asking the host first. If they say it's turned on and working, give them the .htaccess code you're trying to use. Sometimes the rewrite rules are different on some servers. Their tech guys should be able to tell you right away.
     
    nicknick, Dec 8, 2006 IP
  15. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #15
    Nintendo, Dec 8, 2006 IP