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.
    • MickEdwards
      MickEdwards @3plains last edited by

      That last rule is the Wordpress default rule slightly trimmed:

      <ifmodule mod_rewrite.c="">RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]</ifmodule>

      I would try this version and revert if no good.  I'd also install Fiddler and watch all the header responses to see if there is a clue.

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

        Tried it, and same result as before.

        I've even tried this from SEOmoz:

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

        ....and it gave my server an error. I don't know I guess something funky is going on.

        MickEdwards 1 Reply Last reply Reply Quote 0
        • 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
                            • Where to put 301 redirects in my Wordpress htaccess file?
                              Benspain
                              Benspain
                              0
                              3
                              34

                            • 301 redirect syntax for htaccess
                              IOHanna
                              IOHanna
                              1
                              3
                              6.0k

                            • .htaccess Redirect 301 issues
                              Cyberace
                              Cyberace
                              0
                              5
                              140

                            • Redirect a 301 Redirect
                              RedCaffeine
                              RedCaffeine
                              0
                              5
                              98

                            • Redirecting special characters in .htaccess and web.config
                              stephenfishman
                              stephenfishman
                              0
                              7
                              10.6k

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

                            • Redirect or not to redirect
                              AlanMosley
                              AlanMosley
                              0
                              7
                              458

                            • Redirects on Window Servers - .htaccess equivalent for IIS
                              Getz.pro
                              Getz.pro
                              0
                              2
                              4.1k

                            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