.htaccess file for windows hosting - give me your valuable suggestion

Discussion in 'Programming' started by Nicker, Jun 1, 2010.

  1. #1
    Hi,
    I have tried upload .htaccess for URL redirection for my website. But it looks the code is not working.

    I have hosted my site in Windows server. Kindly help me how to clear that error. Below is code i used in the .htaccess file what I have uploaded.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.htm\ HTTP/
    RewriteRule index\.htm$ http://www.mysite.com/%1 [R=301,L]
    ErrorDocument 404 /AnErrorPage.html
     
    Nicker, Jun 1, 2010 IP
  2. trevHCS

    trevHCS Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First thing to check is whether the server is running Apache or IIS? A lot of Windows servers run IIS as it integrates easily in which case .htaccess won't do anything.

    I'd comment out the second RewriteCond and RewriteRule with # and see if it then at least redirects from the non www. to the www. version. Easiest to break the thing down and then see what works. The first 2 rules look like they should work.

    The other two are a bit complicated to read currently, but if the above works then we could look closer at them.

    Trev
     
    trevHCS, Jun 2, 2010 IP
  3. Nicker

    Nicker Active Member

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    As you said my site is hosted in Server: Microsoft-IIS/6.0 , But could you please give me a clear idea on how to edit the rule using #

    Nick

     
    Nicker, Jun 2, 2010 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    IIS mod-rewrite modules exist for IIS but it doesn't come with the ability to rewrite urls on its own. You will need either a third party plugin or do it the cool dude way, setup IIS to have ASP.NET's engine handle the web-requests and control it all manually - look into the MVC, which I believe comes with that power.
     
    ccoonen, Jun 2, 2010 IP
  5. Nicker

    Nicker Active Member

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    I will try it out too..
     
    Nicker, Jun 2, 2010 IP