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 problem using POST method

    .htaccess problem using POST method

    Technical SEO Issues
    4 2 1.5k
    • 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.
    • TrevorJones
      TrevorJones last edited by

      Hi guys

      I'm after some help with trying to achieve the following:

      1. Canonicalise to http://www.

      2. Remove the index.php from root and subfolders.

      I have the .htaccess code below, which seemed to work fine, but the urls use the POST method and this isn't working with the rewrites.

      Can anyone please advise as to what I am doing wrong? As you can probably guess .htaccess isn't my strongest SEO discipline!

      The code I have is:

      http:// to http://www.

      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^mydomainexample.com
      RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]

      /index.php to /

      Options +FollowSymLinks
      DirectoryIndex index.php

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/
      RewriteRule ^index.php$ http://www.mydomainexample.com/ [R=301,L]

      Subdirectory /index.php to /

      RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)index.(php|html|htm?)[#?]?
      RewriteRule ^(([^/]+/)
      )index.(php|html|htm?)$ http://www.mydomainexample.com/$1 [R=301,L]

      Just to add to this I have found this which I think is what I need to restrict it to GET:

      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
      
      Thank you in advance for any suggestions as to how I may put this code together..
      

      Trevor

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

        Hi guys

        Not sure if I can get mozpoints for answering my own question - perhaps someone can thumb it up 😉

        Anyway below is the .htaccess code that seems to work for canonicalization and allowing POST:

        http:// to http://www.

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^mydomainexample.com
        RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]

        REDIRECT /folder/index.php to /folder/

        RewriteCond %{THE_REQUEST} ^GET.index.php\ HTTP/
        RewriteRule ^(([^/]+/)
        )index.php$ http://www.mydomainexample.com/$1 [R=301,L]

        Cheers

        KeriMorgret 1 Reply Last reply Reply Quote 1
        • KeriMorgret
          KeriMorgret @TrevorJones last edited by

          I gave you a thumbs up! Glad you solved this, and I'm sure it'll help someone in the future. Thanks for posting the answer!

          TrevorJones 1 Reply Last reply Reply Quote 0
          • TrevorJones
            TrevorJones @KeriMorgret last edited by

            Hi Keri

            Thanks for the thumbs up 🙂

            Must be a lot of people out there with the same question; the post on this topic, on my site, gets a lot of visitors.

            Thanks again.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Pros and Cons of using rel=next on blog posts
              ViviCa1
              ViviCa1
              0
              2
              68

            • Will a blog post about a collection of useful tools and web resources for a specific niche being seen as negative by google for too many links?
              ericzou
              ericzou
              0
              5
              113

            • Duplicate url problem causing me problems
              PaulRonin
              PaulRonin
              0
              6
              246

            • I cannot find a way to implement to the 2 Link method as shown in this post: http://searchengineland.com/the-definitive-guide-to-google-authorship-markup-123218
              Mark.RedGiant
              Mark.RedGiant
              0
              7
              459

            • Is it better to guest post with or without using rel=author?
              EricaMcGillivray
              EricaMcGillivray
              0
              3
              530

            • Problem? Use no follow with paid advertisers ? Or Duplicate site www.
              EGOL
              EGOL
              0
              2
              340

            • Is the same content posted under different international TLDs a problem?
              Mattbyo
              Mattbyo
              0
              3
              924

            • 301 redirect .htaccess problem
              sferrino
              sferrino
              0
              4
              709

            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