Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Moz API
      • Moz API Home
      • Compare SEO Products
      • Moz Data
    • Free SEO Tools
      • Domain Analysis
      • Keyword Explorer
      • Link Explorer
      • Competitive Research
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your all-in-one suite of SEO essentials.

      • Moz Local

        Raise your local SEO visibility with complete local SEO management.

      • STAT

        SERP tracking and analytics for enterprise SEO experts.

      • Moz API

        Power your SEO with our index of over 44 trillion links.

      • Compare SEO Products

        See which Moz SEO solution best meets your business needs.

      • Moz Data

        Power your SEO strategy & AI models with custom data solutions.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Free SEO Tools
      • Domain Analysis

        Get top competitive SEO metrics like DA, top pages and more.

      • Keyword Explorer

        Find traffic-driving keywords with our 1.25 billion+ keyword index.

      • Link Explorer

        Explore over 40 trillion links for powerful backlink data.

      • Competitive Research

        Uncover valuable insights on your organic search competitors.

      • MozBar

        See top SEO metrics for free as you browse the web.

      • More Free SEO Tools

        Explore all the free SEO tools Moz has to offer.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

      • SEO Q&A

        Insights & discussions from an SEO community of 500,000+.

      Unlock flexible pricing & new endpoints
      Moz API

      Unlock flexible pricing & new endpoints

      Find your plan
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

      • New Releases

        Get the scoop on the latest and greatest from Moz.

      Surface actionable competitive intel
      New Feature

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Moz API
      • Moz API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. Home
    2. SEO Tactics
    3. Technical SEO
    4. Add trailing slash after removing .html extention

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    Add trailing slash after removing .html extention

    Technical SEO
    3
    5
    1355
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question management privileges can see it.
    • Uber_
      Uber_ last edited by

      My website is non www ,it has wordpress in subdirectory and some static webpages in the root and other subdirectory

      1. i want to remove .html extention from the webpages in the root and
      the others static webpages in subdirectory.
      2. add slash at the end.
      3. 301 redirect from non slash to url with slash.

      so it should be

      http://ghadaalsaman.com/articles.html to http://ghadaalsaman.com/articles/

      and

      http://ghadaalsaman.com/en/poem-list.html to http://ghadaalsaman.com/en/poem-list/

      the below code

      1. working with non slash at the end

      **2. **redirect 301 url with slash to non

      here's my .htaccess

      <ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews

      RewriteEngine On
      RewriteBase /</ifmodule>

      #removing trailing slash
      RewriteCond %{REQUEST_FILENAME} !-d     
      RewriteRule ^(.*)/$ $1 [R=301,L]

      #www to non
      RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
      RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

      #html
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^.]+)$ $1.html [NC,L]

      #index redirect
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
      RewriteRule ^index.html$ http://ghadaalsaman.com/ [R=301,L]
      RewriteCond %{THE_REQUEST} .html
      RewriteRule ^(.*).html$ /$1 [R=301,L]

      PS everything is ok with the wordpress , the problems with static pages only.

      Thanks in advanced

      1 Reply Last reply Reply Quote 0
      • NeatIT
        NeatIT @BMullz last edited by

        Not Working

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

          Can you please try the above but delete:

          #removing trailing slash
          RewriteCond %{REQUEST_FILENAME} !-d     
          RewriteRule ^(.*)/$ $1 [R=301,L]

          Let me know if that works.

          NeatIT 1 Reply Last reply Reply Quote 0
          • Uber_
            Uber_ @BMullz last edited by

            i tried that code and not working

            <ifmodule mod_rewrite.c=""> 
            Options +FollowSymLinks -MultiViews

            RewriteEngine On 
            RewriteBase /</ifmodule>

            #removing trailing slash
            RewriteCond %{REQUEST_FILENAME} !-d     
            RewriteRule ^(.*)/$ $1 [R=301,L]

            #www to non
            RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
            RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

            #html
            RewriteCond %{REQUEST_FILENAME} !-f 
            RewriteCond %{REQUEST_FILENAME} !-d 
            RewriteRule ^([^.]+)$ $1.html [NC,L]

            #index redirect 
            RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/ 
            RewriteRule ^index.html$ http://ghadaalsaman.com/ [R=301,L]
            RewriteCond %{THE_REQUEST} .html 
            RewriteRule ^(.*).html$ /$1 [R=301,L]

            #moz
            RewriteRule ^(.*)$ http://ghadaalsaman.com.com/$1/ [L,R=301]

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

              Hi Uber_,

              Typically this is handled is by adding the following to your .htaccess file:

              RewriteCond %{REQUEST_FILENAME} !-f              <--looks like your version of this would also work fine.
              
              RewriteCond %{REQUEST_URI} !index.php             <---This is very optional. If there are any .php files you don't want to be rewritten add their .endpath here.
              
              RewriteCond %{REQUEST_URI} !(.*)/$                   <----Looks like you have this, which determines which url doesn't have a trailing slash.
              
              RewriteRule ^(.*)$ http://ghadaalsaman.com.com/$1/ [L,R=301]    <----This would add a trailing slash and then redirect to the new URL.
              
              Highly recommend you add the last line because both of your / and non / ending urls are populating (which could cause duplicate content issues). This will also help with allocating proper page authority.
              
              Hope this helps,
              B
              
              Uber_ 1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              Got a burning SEO question?

              Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


              Start my free trial


              Browse Questions

              Explore more categories

              • Moz Tools

                Chat with the community about the Moz tools.

              • SEO Tactics

                Discuss the SEO process with fellow marketers

              • Community

                Discuss industry events, jobs, and news!

              • Digital Marketing

                Chat about tactics outside of SEO

              • Research & Trends

                Dive into research and trends in the search industry.

              • Support

                Connect on product support and feature requests.

              • See all categories

              Related Questions

              • m1700

                does <base> in html affect seo?

                hey, just wanna know  does <base> in head of website affect SEO? and if it's a yes, how?

                Technical SEO | | m1700
                1
              • Deacyde

                Canonical homepage link uses trailing slash while default homepage uses no trailing slash, will this be an issue?

                Hello, 1st off, let me explain my client in this case uses BigCommerce, and I don't have access to the backend like most other situations. So I have to rely on BG to handle certain issues. I'm curious if there is much of a difference using domain.com/ as the canonical url while BG currently is redirecting our domain to domain.com. I've been using domain.com/ consistently for the last 6 months, and since we switches stores on Friday, this issue has popped up and has me a bit worried that we'll loose somehow via link juice or overall indexing since this could confuse crawlers. Now some say that the domain url is fine using / or not, as per - https://moz.com/community/q/trailing-slash-and-rel-canonical But I also wanted to see what you all felt about this. What says you?

                Technical SEO | | Deacyde
                0
              • CallMeNicholi

                Last Part Breadcrumb Trail Active or Non-Active

                Breadcrumbs have been debated quite a bit in the past. Some claim that the last part of the breadcrumb trail should be non-active to inform users they have reached the end. In other words, Do not link the current page to itself. On the other hand, that portion of the breadcrumb would won't be displayed in the SERPS and if it was may lead to a higher CTR. Foe example: www.website.com/fans/panasonic-modelnumber panasonic-modelnumber would not be active as part of the breadcrumb. What is your take?

                Technical SEO | | CallMeNicholi
                0
              • agencycentral

                Noindex vs. page removal - Panda recovery

                I'm wondering whether there is a consensus within the SEO community as to whether noindexing pages vs. actually removing pages is different from Google Pandas perspective?Does noindexing pages have less value when removing poor quality content than physically removing ie. either 301ing or 404ing the page being removed and removing the links to it from the site? I presume that removing pages has a positive impact on the amount of link juice that gets to some of the remaining pages deeper into the site, but I also presume this doesn't have any direct impact on the Panda algorithm? Thanks very much in advance for your thoughts, and corrections on my assumptions 🙂

                Technical SEO | | agencycentral
                0
              • JaredMumford

                Removing URL Parentheses in HTACCESS

                Im reworking a website for a client, and their current URLs have parentheses. I'd like to get rid of these, but individual 301 redirects in htaccess is not practical, since the parentheses are located in many URLs. Does anyone know an HTACCESS rule that will simply remove URL parantheses as a 301 redirect?

                Technical SEO | | JaredMumford
                0
              • NetPicks

                How do I redirect index.html to the root / ?

                The site I've inherited had operated on index.html at one point, and now uses index.php for the home page, which goes to the / page. The index.html was lost in migrating server hosts. How do I redirect the index.html to the / page? I've tried different options that keep giving ending up with the same 404 error. I tried a redirect from index.html to index.php which ended in an infinite loop. Because the index.html no longer exists in the root, should I created it and then add a redirect to it? Can I avoid this by editing the .htaccess? Any help is appreciated, thanks in advance!

                Technical SEO | | NetPicks
                0
              • Jinx14678

                How Add 503 status to IIS 6.0

                Hi, Our IS department is bringing down our network for maintenance this weekend for 24 hours. I am worried about search engine implications. all Traffic is being diverted, and the diverted traffic is being sent to another server with IIS 6.0 From all research i have done it appears creating a custom 503 error message in IIS 6 is not possible  Source: http://technet.microsoft.com/en-us/library/bb877968.aspx So my question is does anyone have any suggestions on how to do a proper 503 temporarily unavailable in IIS 6.0 with a custom error message? Thanks

                Technical SEO | | Jinx14678
                0
              • DavidS-282061

                Are .html pages better for ranking than .asp pages

                It seems that .html pages do better for the long tail...

                Technical SEO | | DavidS-282061
                0

              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
              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 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
              • Accessibility
              • Terms of Use
              • Privacy

              Looks like your connection to Moz was lost, please wait while we try to reconnect.