5 replies
  • WEB DESIGN
  • |
I've noticed that one of my sites is showing up in Yahoo and Bing organic search as: www.mysite.com/index.htm but it is showing correctly in Google organic.

It is an HTML site and I'm trying to find what I can put into the .htaccess file to 301 redirect www.mysite.com/index.htm to www.mysite.com.

I have already successfully redirected the non-www to the www
#htaccess #question
  • Profile picture of the author topnichewebsites
    Try This: ... removes index.html and index.htm

    RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
    RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE,L]
    Signature
    http://pixelcovers.com/ <- eBook add eCovers

    https://www.unicommercesolutions.com <- WordPress Websites and Maintenance
    {{ DiscussionBoard.errors[6097376].message }}
    • Profile picture of the author mraffiliate
      Originally Posted by topnichewebsites View Post

      Try This: ... removes index.html and index.htm

      RewriteCond %{REQUEST_URI} /index.html?$ [NC]
      RewriteRule ^(.*)index.html?$ "/$1" [NC,R=301,NE,L]
      Thanks for this. I failed to mention that I'm using a hosting company that allows for multiple domains/sites on one account so this site that I'm referring too is not in the root directory. It is in a folder in the root, so it will have it's own .htaccess file separate from the root directory's .htaccess file.

      1- site 1 = /
      2- site 2 = /site2directory
      3- site 3 = /site3directory
      etc.
      Signature

      {{ DiscussionBoard.errors[6098123].message }}
  • Profile picture of the author elitewebdesign
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[6101425].message }}
    • Profile picture of the author mraffiliate
      Originally Posted by elitewebdesign View Post

      when someone tries to go to a non-existant page the server is going to give a 404 error. So what your htaccess has to do is trap that error code and redirect it to your custom 40 page, or any page you want.
      when you type in www.mysite.com and www.mysite.com/index.htm they both bring up my HomePage correctly. Yahoo and Bing decided to index the /index.htm version. I just wanted to 301 redirect the /index.htm version to the .com.

      The issue I had was that this site isn't in the root directory on my server. My hosting allows for multiple sites on one account so this site is in a separate directory so I wasn't sure how to correctly fill in the .htaccess file.
      Signature

      {{ DiscussionBoard.errors[6101487].message }}
      • Profile picture of the author aisdbuilder
        I'm not sure if this will help with the way your hosting is set up but, using the snippet above, you could try adding the subdirectories like this:

        RewriteCond %{REQUEST_URI} /sitedirectory2/index.html?$ [NC]
        RewriteRule ^(.*)index.html?$ "/$1" [NC,R=301,NE,L]

        Not sure if that will help but maybe worth a try.
        {{ DiscussionBoard.errors[6107082].message }}
        • Profile picture of the author mraffiliate
          Originally Posted by aisdbuilder View Post

          I'm not sure if this will help with the way your hosting is set up but, using the snippet above, you could try adding the subdirectories like this:

          RewriteCond %{REQUEST_URI} /sitedirectory2/index.html?$ [NC]
          RewriteRule ^(.*)index.html?$ "/$1" [NC,R=301,NE,L]

          Not sure if that will help but maybe worth a try.
          Thanks, I'll try this tomorrow
          Signature

          {{ DiscussionBoard.errors[6108776].message }}

Trending Topics