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. Web Design
    4. WordPress and Redirects

    WordPress and Redirects

    Web Design
    14 4 149
    • 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.
    • WilliamKammer
      WilliamKammer last edited by

      I've never done this specific rule, but it would definitely be a rewrite rule in your .htaccess file in your root. You can give this piece a shot:

      RewriteEngine On

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*).html\ HTTP/

      RewriteRule .* http://localhost/html/%1 [R=301,L]

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*)\ HTTP/

      RewriteRule .* %1.html [L]

      Jeez.... how do I get rid of all the extra spacing?!

      Anyway, if that doesn't work, there are some other options here: http://stackoverflow.com/questions/5730092/how-to-remove-html-from-url

      And if you need to customize the regex a bit, this can help: http://www.regexr.com/

      Travis_Bailey 1 Reply Last reply Reply Quote 2
      • Travis_Bailey
        Travis_Bailey @WilliamKammer last edited by

        <ifmodule mod_rewrite.c="">RewriteEngine On
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.).html\ HTTP/
        RewriteRule .
        http://localhost/html/%1 [R=301,L]
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.)\ HTTP/
        RewriteRule .
        %1.html [L]</ifmodule>

        Travis_Bailey 1 Reply Last reply Reply Quote 0
        • Travis_Bailey
          Travis_Bailey @Travis_Bailey last edited by

          Curly brackets between the unlink and bold portions of the kitchen sink. Apparently you have to make sure you've said what you need to say, because I couldn't find a way to intuitively shut off the block and type.

          WilliamKammer 1 Reply Last reply Reply Quote 1
          • RobDalton
            RobDalton last edited by

            Thanks for the feedbacks.  I tried the above code.  I also tried a few at the website above and did not have any luck.  Just to confirm what I am trying to do......Take a page like www.waikoloavacationrentals.com/kolea-rentals/9g.html.  If someone types in www.waikoloavacationrentals.com/kolea-rentals/9g I want it to go to www.waikoloavacationrentals.com/kolea-rentals/9g.html so that they do not get a blank page.  It was happening on my old site, but not having the same luck with wordpress.  Thanks again!

            WilliamKammer 1 Reply Last reply Reply Quote 0
            • WilliamKammer
              WilliamKammer @RobDalton last edited by

              The code above will do the opposite.

              domain.com/page.html will become domains.com/page

              Did you test for that? Usually this is how people prefer their URLs to be, and if they type in the .html, they'll still get to the page.

              1 Reply Last reply Reply Quote 0
              • WilliamKammer
                WilliamKammer @Travis_Bailey last edited by

                Thanks! Although, yeah, not very easy to play with.

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

                  Yes.  I am not getting anything on www.waikoloavacationrentals.com/kolea-rentals/9g

                  I don't really care which way the rule goes just as long as when they put in either url they get something.

                  Here is the code incase I typo'd something.

                  <ifmodule mod_rewrite.c="">RewriteEngine On
                  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.).html\ HTTP/
                  RewriteRule .
                  http://www.waikoloavacationrentals.com/html/%1 [R=301,L]
                  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.)\ HTTP/
                  RewriteRule .
                  %1.html [L]</ifmodule>

                  WilliamKammer 1 Reply Last reply Reply Quote 0
                  • WilliamKammer
                    WilliamKammer @RobDalton last edited by

                    don't put your URL in for line 4, keep it as "localhost" like in the example.

                    RobDalton 1 Reply Last reply Reply Quote 0
                    • RobDalton
                      RobDalton @WilliamKammer last edited by

                      That is what I originally had.  I put it back.

                      <ifmodule mod_rewrite.c="">RewriteEngine On
                      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.).html\ HTTP/
                      RewriteRule .
                      http://localhost/html/%1 [R=301,L]
                      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.)\ HTTP/
                      RewriteRule .
                      %1.html [L]</ifmodule>

                      Try clicking on www.waikoloavacationrentals.com/kolea-rentals/9g and you will see what happens.  Thanks,

                      WilliamKammer 1 Reply Last reply Reply Quote 0
                      • WilliamKammer
                        WilliamKammer @RobDalton last edited by

                        Mind PMing me your. Htaccess?

                        RobDalton 1 Reply Last reply Reply Quote 0
                        • RobDalton
                          RobDalton @WilliamKammer last edited by

                          I sent it over.

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

                            Still no luck on this one if anyone else has any insight.

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

                              Pages load correct at: http://www.waikoloavacationrentals.com/kolea-rentals/9g.html

                              And do not load at: http://www.waikoloavacationrentals.com/kolea-rentals/9g

                              So you need to Redirect http://www.waikoloavacationrentals.com/kolea-rentals/9g TO http://www.waikoloavacationrentals.com/kolea-rentals/9g.html

                              You can do this with the line of code in .htaccess

                              Redirect 301 /kolea-rentals/9g http://www.waikoloavacationrentals.com/kolea-rentals/9g.html

                              Let us know if that works?

                              You can also try the redirect plugin, although personally I prefer using .htaccess for redirects

                              1 Reply Last reply Reply Quote 0
                              • 1 / 1
                              • First post
                                Last post
                              • Does redirecting the existing URLs in the website without reducing our current rankings? The new website runs on the bubble, so it seems there is no provisions to redirect the existing URLs to this platform?
                                0
                                1
                                51

                              • I want to create a 301 redirect on a WordPress site, nothing's working...
                                MattRoney
                                MattRoney
                                0
                                4
                                129

                              • 301 htaccess redirect or 301 HTTP DNS Redirect
                                OlegKorneitchouk
                                OlegKorneitchouk
                                0
                                2
                                1.4k

                              • Wordpress - redirecting tags
                                GPainter
                                GPainter
                                0
                                3
                                230

                              • Is it necessary to Remove 301 redirects from Wordpress after removing the 404 url from Google Webmaster?
                                JCurrier
                                JCurrier
                                0
                                3
                                252

                              • Switching over to wordpress
                                evolvingSEO
                                evolvingSEO
                                0
                                5
                                129

                              • Wordpress in a subdirectory?
                                GregDixson
                                GregDixson
                                0
                                5
                                3.0k

                              • Wordpress templates
                                Doc_Sheldon
                                Doc_Sheldon
                                0
                                9
                                1.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

                              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