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

              • SarahLK

                Removed Subdomain Sites Still in Google Index

                Hey guys, I've got kind of a strange situation going on and I can't seem to find it addressed anywhere.  I have a site that at one point had several development sites set up at subdomains.  Those sites have since launched on their own domains, but the subdomain sites are still showing up in the Google index.  However, if you look at the cached version of pages on these non-existent subdomains, it lists the NEW url, not the dev one in the little blurb that says "This is Google's cached version of www.correcturl.com."  Clearly Google recognizes that the content resides at the new location, so how come the old pages are still in the index?  Attempting to visit one of them gives a "Server Not Found" error, so they are definitely gone. This is happening to a couple of sites, one that was launched over a year ago so it doesn't appear to be a "wait and see" solution. Any suggestions would be a huge help.  Thanks!!

                Technical SEO | | SarahLK
                0
              • benseb

                Remove page with PA of 69 and 300 root domain links?

                Hi We have a few pages within our website which were at one time a focus for us, but due to developing the other areas of the website, they are now defunct (better content elsewhere) and in some ways slightly duplicate so we're merging two areas into one. We have removed the links to the main hub page from our navigation, and were going to 301 this main page to the main hub page of the section which replaces it. However I've just noticed the page due to be removed has a PA of 69 and 15,000 incoming links from 300 root domains. So not bad! It's actually stronger than the page we are 301'ing it to (but not really an option to swap as the URL structure will look messy) With this in mind, is the strategy to redirect still the best or should we keep the page and turn it into a landing page, with links off to the other section? It just feels as though we would be doing this just for the sake of google, im not sure how much decent content we could put on it as we've already done that on the destination page. The incoming links to that page will still be relevant to the new section (they are both v similar hence the merging) Any suggestions welcome, thanks

                Technical SEO | | benseb
                0
              • inlinear

                Correct linking to the /index of a site and subfolders: what's the best practice? link to: domain.com/ or domain.com/index.html ?

                Dear all, starting with my .htaccess file: RewriteEngine On
                RewriteCond %{HTTP_HOST} ^www.inlinear.com$ [NC]
                RewriteRule ^(.*)$ http://inlinear.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^./index.html 
                RewriteRule ^(.)index.html$ http://inlinear.com/ [R=301,L] 1. I redirect all URL-requests with www. to the non www-version...
                2. all requests with "index.html" will be redirected to "domain.com/" My questions are: A) When linking from a page to my frontpage (home) the best practice is?: "http://domain.com/" the best and NOT: "http://domain.com/index.php" B) When linking to the index of a subfolder "http://domain.com/products/index.php" I should link also to: "http://domain.com/products/" and not put also the index.php..., right? C) When I define the canonical ULR, should I also define it just: "http://domain.com/products/" or in this case I should link to the definite file: "http://domain.com/products**/index.php**" Is A) B) the best practice? and C) ? Thanks for all replies! 🙂
                Holger

                Technical SEO | | inlinear
                0
              • Veva

                Can I remove 301 redirects after some time?

                Hello, We have an very large number of 301 redirects on our site and would like to find a way to remove some of them. Is there a time frame after which Google does not need a 301 any more? For example if A is 301 redirected to B, does Google know after a while not to serve A any more, and replaces any requests for A with B? How about any links that go to A? Or: Is the only option to have all links that pointed to A point to B and then the 301 can be removed after some time? Thank you for you you help!

                Technical SEO | | Veva
                0
              • SmartWebPros

                How to search HTML source for an entire website

                Is there a way for me to do a "view source" for an entire website without having to right-click every page and select "view source" for each of them?

                Technical SEO | | SmartWebPros
                0
              • Chammy

                How much impact does bad html coding really have on SEO?

                My client has a site that we are trying to optimise. However the code is really pretty bad. There are 205 errors showing when W3C validating. The >title>, , <keywords> tags are appearing twice. There is truly excessive javascript. And everything has been put in tables.</keywords> How much do you think this is really impacting the opportunity to rank? There has been quite a bit of discussion recently along the lines of is on-page SEO impacting anymore. I just want to be sure before I recommend a whole heap of code changes that could cost her a lot - especially if the impact/return could be miniscule. Should it all be cleaned up? Many thanks

                Technical SEO | | Chammy
                0
              • ErnieB

                Subdomain Removal in Robots.txt with Conditional Logic??

                I would like to see if there is a way to add conditional logic to the robots.txt file so that when we push from DEV to PRODUCTION and the robots.txt file is pushed, we don't have to remember to NOT push the robots.txt file OR edit it when it goes live. My specific situation is this: I have www.website.com, dev.website.com and new.website.com and somehow google has indexed the DEV.website.com and NEW.website.com and I'd like these to be removed from google's index as they are causing duplicate content. Should I: a) add 2 new GWT entries for DEV.website.com and NEW.website.com and VERIFY ownership - if I do this, then when the files are pushed to LIVE won't the files contain the VERIFY META CODE for the DEV version even though it's now LIVE? (hope that makes sense) b) write a robots.txt file that specifies "DISALLOW: DEV.website.com/" is that possible? I have only seen examples of DISALLOW with a "/" in the beginning... Hope this makes sense, can really use the help!  I'm on a Windows Server 2008 box running ColdFusion websites.

                Technical SEO | | ErnieB
                0
              • BostonWright

                Restaurant menu SEO: PDF or HTML?

                Is it better to use a PDF or hard code restaurant menus (or any document for that matter) in HTML? I want the content to be indexed and thought PDF was the way to go for several reasons, but I wanted to get confirmation on this before I move forward.

                Technical SEO | | BostonWright
                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

              Access all your tools in one place. Whether you're tracking progress or analyzing data, everything you need is at your fingertips.

              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.