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 redirects

    .htaccess redirects

    Technical SEO Issues
    15 4 285
    • 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.
    • ThompsonPaul
      ThompsonPaul last edited by

      Ryan, it seems there must be a conflict in your htaccess file? If you're willing, you can PM me a copy of the full file and the site URL and I'll see if i can find anything.

      Paul

      3plains 1 Reply Last reply Reply Quote 1
      • MickEdwards
        MickEdwards @3plains last edited by

        i'd try disabling all plugins and test.  Also ensure in General >> Settings the URLs are including the www (I assume this is Wordpress). There seems to be some internal configuration causing this.

        1 Reply Last reply Reply Quote 0
        • 3plains
          3plains @ThompsonPaul last edited by

          Sent you an email.

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

            Hi Ryan,

            For non-www to www redirects (for all the URLs under the domain) you can use:

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

            Thanks!

            3plains 1 Reply Last reply Reply Quote 0
            • 3plains
              3plains @Aleyda last edited by

              Tried it,

              Same results as above.

              Aleyda 1 Reply Last reply Reply Quote 0
              • Aleyda
                Aleyda @3plains last edited by

                It's there something else then in your htaccess? I also checked it with http://htaccess.madewithlove.be/ and worked fine. Could you please test it with another domain so you can take a look it's ok? I'm afraid that it might be something else that you have configured there and that's why it doesn't work since the code is alright.

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

                  Hi again. I've just seen your answer above, that you also have the following:

                  RewriteEngine on
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule . index.php [L]

                  In your htaccess so I've added it before too:

                  RewriteEngine on
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule . index.php [L]

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

                  and again worked fine! Do you have something additional to that?

                  Thanks!

                  3plains 1 Reply Last reply Reply Quote 0
                  • 3plains
                    3plains @Aleyda last edited by

                    Hey Aleyda,

                    Thanks for the help, but unfortunately it still won't work. There are 2 other pieces of info in my .htaccess file.

                    1. Some PHP stuff (not sure what it does)

                    Use PHP 5.3

                    AddType application/x-httpd-php53 .php

                    2. 301 redirects I did a few days ago (about 30 articles that looks like this)

                    Redirect 301 /article http://www.example.com/blog/article

                    Redirect 301 /article2 http://www.example.com/blog/article2

                    ....It must be one of these two remaining issues...?

                    ThompsonPaul 1 Reply Last reply Reply Quote 0
                    • 3plains
                      3plains last edited by

                      Paul figured it out. You the man!

                      1 Reply Last reply Reply Quote 0
                      • ThompsonPaul
                        ThompsonPaul @3plains last edited by

                        The php declaration is to force your server to use php version 5.3, 3Plains. It's often put in place when a site's applications require a more recent version of php than is the default on the server.

                        @Aleya - his htaccess had the php declaration in the middle of some of his conditionals, which I suspect was the issue. Had him move the php declaration to the top of the file before turning rewrite engine on. Seems to have resolved the issue.

                        (Note, the php declaration can also be placed as last line in the file. I just find it better at the top so it reminds it's there in case I have a php version issue after a future server upgrade)

                        Pleased we got ya working 🙂

                        Paul

                        1 Reply Last reply Reply Quote 1
                        • 1 / 1
                        • First post
                          Last post
                        • 301 redirects without .htaccess
                          NancyVPS
                          NancyVPS
                          0
                          5
                          2.0k

                        • .htaccess redirect question
                          David-Kley
                          David-Kley
                          0
                          4
                          541

                        • .htaccess Redirect 301 issues
                          Cyberace
                          Cyberace
                          0
                          5
                          140

                        • 301 redirect .htaccess
                          Christy-Correll
                          Christy-Correll
                          0
                          5
                          234

                        • Htaccess redirect with question mark
                          darkanweb
                          darkanweb
                          0
                          3
                          2.2k

                        • Htaccess redirects how many can i have and does it slow site down
                          ClaireH-184886
                          ClaireH-184886
                          0
                          3
                          1.2k

                        • Redirect or not to redirect
                          AlanMosley
                          AlanMosley
                          0
                          7
                          458

                        • 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

                        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