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. Redirect url that don't end with slash

    Redirect url that don't end with slash

    Technical SEO Issues
    4 3 173
    • 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.
    • arielbortz
      arielbortz last edited by

      Hi!

      I need to add in my .htaccess a way to redirect URL that don't end with / to the one thats end wth /.For example, I need http://example.com to redirect to http://www.example.com/. And, of course, this redirection should be only for URLs that don't end with /, so I don't get double // at the end.

      I already have the code to redirect the non-www to the www, but can't find a way to do the slash thing.

      Thanks!

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

        Hi Ariel,

        I have found something on Stackoverflow: http://stackoverflow.com/questions/7780859/htaccess-rewrite-to-force-trailing-slash-at-the-end

        Maybe you want to check it out, if it works for you.

        Gr., Keszi

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

          do you have a number of URLS that you need to redirect ? or do you just want to redirect http://example.com to http://www.example.com/

          This will add trailing slash to any URL

          Add a trailing slash

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
          RewriteRule ^(.*)$ $1/ [L,R=301]

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

            Thank you both!

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • I need help with redirecting chain to another page and 301, I don't understand on how to fix
              salem4e
              salem4e
              0
              3
              111

            • Redirect 'keyword-url' to improve ranking?
              Jan-Peter
              Jan-Peter
              0
              3
              68

            • Google couldn't follow your URL because it redirected too many times.
              Everett
              Everett
              0
              7
              1.8k

            • OSE says URL redirects to URL with trailing slash but it doesn't.
              rock22
              rock22
              0
              5
              211

            • Carl errors on urls that don't normally exist
              SanketPatel
              SanketPatel
              0
              2
              235

            • Is it better to delete web pages that I don't want anymore or should I 301 redirect all of the pages I delete to the homepage or another live page?
              EGOL
              EGOL
              0
              2
              417

            • Google Webmaster Showing Crawl Errors to URLs that don't exist?
              raylau
              raylau
              0
              4
              604

            • Url's don't want to show up in google. Please help?
              RyanKent
              RyanKent
              0
              5
              587

            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