The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Htaccess file help

    Htaccess file help

    Technical SEO Issues
    4 2 120
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • McSEO
      McSEO last edited by

      Hi, thanks for looking

      i am trying (and failing) to write a htaccess for the following scenario

      <colgroup><col width="679"></colgroup>

      http://www.gardening-services-edinburgh.com/index.html

      http://www.gardening-services-edinburgh.com

      http://www.gardening-services-edinburgh.com/

      |

      so that all of these destinations goto the one resource

      any ideas?

      thanks

      andy

      1 Reply Last reply Reply Quote 0
      • DirkC
        DirkC last edited by

        Hi,

        Normally these rules should do the trick:

        RewriteEngine On

        removes the index (source:http://dense13.com/blog/2012/10/29/removing-index-html-with-mod_rewrite-in-htaccess/)

        RewriteRule ^index.html$ / [R=301,L]                              
        RewriteRule ^(.*)/index.html$ /$1/ [R=301,L]

        adds a trailing slash (source: http://stackoverflow.com/questions/21417263/htaccess-add-remove-trailing-slash-from-url)

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

        Dirk

        McSEO 1 Reply Last reply Reply Quote 1
        • McSEO
          McSEO @DirkC last edited by

          Hi tried that

          heres the code for the.htaccess file

          the problem is when you goto our mobile.gardening-services-edinburgh.com/index.html it comes up with a missing webpage

          however, when you goto mobile.gardening-services-edinburgh.com without the /index.html it comes up with the correct webpage

          any ideas?

          thanks

          #######################################################################

          Diese .htaccess wurde vom STRATO-Webservermanager erstellt

          #######################################################################

          <ifmodule mod_expires.c="">ExpiresActive On
          ExpiresDefault A86400

          Expires after 1 day

          ExpiresByType image/gif A86400
          ExpiresByType image/png A86400
          ExpiresByType image/jpg A86400
          ExpiresByType image/x-icon A86400
          ExpiresByType application/pdf A86400
          ExpiresByType application/x-javascript A86400
          ExpiresByType text/plain A86400

          Expires after 1 day

          ExpiresByType text/css A86400</ifmodule>

          mod_gzip_on Yes
          <ifmodule mod_deflate.c=""><filesmatch ".(js|css|html|jpg|png|php)$"="">SetOutputFilter DEFLATE</filesmatch></ifmodule>

          Options +FollowSymLinks
          RewriteEngine on
          RewriteCond %{HTTP_HOST} ^gardening-services-edinburgh.com [NC]
          RewriteRule ^(.*)$ http://www.gardening-services-edinburgh.com/$1 [R=301,L]

          RewriteRule ^index.html$ / [R=301,L]

          RewriteRule ^(.*)/index.html$ /$1/ [R=301,L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

          ErrorDocument 401 http://www.gardening-services-edinburgh.com/Error-Lost-Page.html

          ErrorDocument 403 http://www.gardening-services-edinburgh.com/Error-Lost-Page.html

          ErrorDocument 404 http://www.gardening-services-edinburgh.com/Error-Lost-Page.html

          ErrorDocument 500 http://www.gardening-services-edinburgh.com/Error-Lost-Page.html

          1 Reply Last reply Reply Quote 0
          • DirkC
            DirkC last edited by

            When I try the url mobile.gardening-services-edinburgh.com/index.html it seems it's being redirected to http://mobile.gardening-services-edinburgh.com/Mobile/ which is generating a 302 to the lost page.

            Could you try to take out the last 2 lines - they don't seem to work (adding the trailing slash) and I fear that they are generating this issue.

            Like most people on this forum I am not really an expert in regex - you could always try to put your question on a forum like stackoverflow - which is much more technically oriented.

            Dirk

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Set Up htaccess File
              GFD_Chris
              GFD_Chris
              0
              2
              48

            • What's Worse - 404 errors or a huge .htaccess file
              customerparadigm.com
              customerparadigm.com
              0
              3
              304

            • Help creating a 301 redirect in my htaccess file
              Felip3
              Felip3
              0
              4
              108

            • Kill your htaccess file, take the risk to learn a little
              KevinBudzynski
              KevinBudzynski
              0
              2
              373

            • Htaccess help... I moved my blog from a seperate domain to newdomain.com/blog
              KristyO
              KristyO
              0
              7
              509

            • Need Help writing 301 redirects in .htaccess file
              Dr-Pete
              Dr-Pete
              0
              5
              1.3k

            • .htaccess file in wordpress blog
              seoug_2005
              seoug_2005
              0
              5
              449

            • I need some HTACCESS help (Magento)
              ShaMenz
              ShaMenz
              0
              6
              938

            Get started with Moz Pro!

            Unlock the power of advanced SEO tools and data-driven insights.

            Start my free trial
            Products
            • Moz Pro
            • Moz Local
            • Moz API
            • Moz Data
            • STAT
            • Product Updates
            Moz Solutions
            • SMB Solutions
            • Agency Solutions
            • Enterprise Solutions
            • Digital Marketers
            Free SEO Tools
            • Domain Authority Checker
            • Link Explorer
            • Keyword Explorer
            • Competitive Research
            • Brand Authority Checker
            • Local Citation Checker
            • MozBar Extension
            • MozCast
            Resources
            • Blog
            • SEO Learning Center
            • Help Hub
            • Beginner's Guide to SEO
            • How-to Guides
            • Moz Academy
            • API Docs
            About Moz
            • About
            • Team
            • Careers
            • Contact
            Why Moz
            • Case Studies
            • Testimonials
            Get Involved
            • Become an Affiliate
            • MozCon
            • Webinars
            • Practical Marketer Series
            • MozPod
            Connect with us

            Contact the Help team

            Join our newsletter
            Moz logo
            © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
            • Accessibility
            • Terms of Use
            • Privacy