1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Apache Running On Windows Server - 301 Redirect in .htaccess?

Discussion in 'Apache' started by Fight Videos UK, Jun 20, 2008.

  1. #1
    Hi,

    Here's the situation.

    We have apache installed on a Windows Server, and have sucessfully setup a WP blog as well as a static website.

    Wordpress2.5 has built in canonical URL's via PHP, and is working fine. Our problem is forcing the 301 on the rest of the website and it's subdirectories.

    I have tried forcing a 301 redirect for canonical URLS (change non-www urls to www) and with each attempt, the site either returns a 500 or works fine, but doesn't do the writing.

    Heres the code in the .htaccess

    ##################################################
    # CANONICAL HOSTNAME REDIRECT (non-www to www)   #
    ##################################################
    
    RewriteEngine On
    RewriteBase / 
    rewritecond %{http_host} ^mydomain\.com [NC]
    rewriterule ^(.*) http://www.mydomain.com/$1 [L, R=301]
    Code (markup):
    *Obviously I am replacing mydomain.com with.... my domain :)

    I'd appreciate any help with this as I've been scratching my head on it. I've got a feeling the problem lies in that this is apache running on windows. I've only ever run *nix servers + apache before, so Im not really sure what needs to be done different?

    Thanks
     
    Fight Videos UK, Jun 20, 2008 IP
  2. Fight Videos UK

    Fight Videos UK Peon

    Messages:
    793
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    just checked with phpinfo() and mod_rewrite IS loaded.... however if I use this code in the .htaccess

    
    <IfModule mod_rewrite.c>
    .......
    </IfModule>
    
    Code (markup):
    then I get a 500 error..... ?
     
    Fight Videos UK, Jun 20, 2008 IP
  3. Fight Videos UK

    Fight Videos UK Peon

    Messages:
    793
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nvm, figured it out. The rewrite rules only work if they are placed in the apache httpd.conf file.... ?
     
    Fight Videos UK, Jun 20, 2008 IP
  4. mellow-h

    mellow-h Peon

    Messages:
    750
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Its not working because your host is not supporting CANONICAL redirection :(
     
    mellow-h, Jun 20, 2008 IP