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 Rewrites

    Htaccess Rewrites

    Technical SEO Issues
    4 2 316
    • 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.
    • Klement69
      Klement69 last edited by

      Hi, I'm battling with duplicate content and would love to fix some redirections in my htaccess file:

      1. I'm trying to use the www version of my site via 301

      2. I'm trying to remove ALL /index.php from my url's

      I currently have the following code, but my home page /index.php is still not redirecting to the root?

      Options +FollowSymLinks
      Options +Indexes

      <ifmodule mod_rewrite.c="">RewriteEngine On
      #RewriteBase /

      RewriteCond %{HTTP_HOST} ^funeralcoverfinder.co.za$ [NC]
      RewriteRule ^(.*)$ http://www.FuneralCoverFinder.co.za/$1 [R=301,NC,L]

      RewriteCond %{QUERY_STRING} base64_encode[^(]([^)]) [OR]
      RewriteCond %{QUERY_STRING} (<|%3C)([^s]s)+cript.(>|%3E) [NC,OR]
      RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
      RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
      RewriteRule .* index.php [F]

      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
      RewriteCond %{REQUEST_URI} !^/index.php
      RewriteCond %{REQUEST_URI} /component/|(/[^.]|.(php|html?|feed|pdf|vcf|raw))$ [NC]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule .
      index.php [L]</ifmodule>

      Any Advice? - Thanks so much!

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

        Hi, 1. Your redirect to www should work. If that isn't working, that might be a sign that mod_rewrite is disabled and in that case, I'd check with your hosting company to verify the server config.

        2. As for the index.php, I wasn't able to get your code working. Here is a code snippet that should remove index.php from all your URLs. It is similar to what you are using, but matches in a different way.

        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.index.php\ HTTP/ RewriteRule ^(.)index.php$ /$1 [R=301,L]

        Hope that helps. Thanks,
        Matthew

        1 Reply Last reply Reply Quote 1
        • Klement69
          Klement69 last edited by

          Thanks so much, I think I got it working now! 🙂

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

            Thanks so much, I think I got it working now! 🙂

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Htaccess noob
              Keszi
              Keszi
              0
              4
              96

            • .htaccess code
              KevinBudzynski
              KevinBudzynski
              0
              8
              68

            • Htaccess mod rewrite from server address
              donford
              donford
              0
              6
              185

            • .htaccess yikes!
              Matt-Williamson
              Matt-Williamson
              0
              8
              79

            • Htaccess file
              DMGoo
              DMGoo
              0
              5
              437

            • Htaccess issue
              sesertin
              sesertin
              0
              8
              487

            • URL Rewrite
              oznappies
              oznappies
              0
              4
              1.0k

            • URL Rewrite
              Gaveltek-173238
              Gaveltek-173238
              0
              13
              1.9k

            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