undefined
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.

    • MozCon

      Save on Early Bird tickets and join us in London or New York City

    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
1.4k
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 Jul 19, 2016, 5:47 AM

    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 Jul 31, 2016, 7:51 PM Jul 31, 2016, 7:51 PM

      Not Working

      1 Reply Last reply Reply Quote 0
      • BMullz
        BMullz last edited by Jul 26, 2016, 1:53 AM Jul 26, 2016, 1:53 AM

        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 Jul 31, 2016, 7:51 PM Reply Quote 0
        • Uber_
          Uber_ @BMullz last edited by Jul 20, 2016, 11:00 AM Jul 20, 2016, 11:00 AM

          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 Jul 19, 2016, 5:50 PM Jul 19, 2016, 5:48 PM

            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 Jul 20, 2016, 11:00 AM Reply Quote 0
            • 1 / 1
            1 out of 5
            • First post
              1/5
              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

            • AliMac26

              Is Removing Breadcrumbs Detrimental for SEO?

              We have full navigational breadcrumbs on our site for the menu and the brand menu. i.e. Home > Clothing > Jackets Brand > Brand Name > Brand Jackets There's been talk of removing this and having it like Chico's does, where on item pages they just have a link at the top to previous category (i.e. you're on a shirt product page and at the top it says "Back to Tops" instead of listing Home > Clothing > Tops) Is doing something like this detrimental to SEO? From what I've read Breadcrumbs are for user experience but I just want to be sure.

              Technical SEO | Mar 16, 2017, 4:34 PM | AliMac26
              0
            • TimHolmes

              301 redirect adding trailing slash to url

              I am looking into a .htacess file for a site I look after and have noticed that the urls are all 301 redirecting from a none slash directory to a trailing slashed directory/folders. e.g. www.domain.com/folder gets 301 redirected to www.domain.com/folder/ Will this do much harm and reduce the effect on the page and any links pointing to the site be lessened? Secondly I am not sure what part of my htaccess is causing the redirect. RewriteCond %{HTTP_HOST} !^www.domain.co.uk [NC] RewriteCond %{HTTP_HOST} !^$
              RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R,NE] RewriteCond %{THE_REQUEST} ^./index.php
              RewriteRule ^(.)index.php$ /$1 [R=301,L] or could a wordpress ifmodule be causing the problem? Any info would be apreciated.

              Technical SEO | Sep 14, 2015, 5:40 AM | TimHolmes
              0
            • sparrowdog

              Using the Google Remove URL Tool to remove https pages

              I have found a way to get a list of 'some' of my 180,000+ garbage URLs now, and I'm going through the tedious task of using the URL removal tool to put them in one at a time. Between that and my robots.txt file and the URL Parameters, I'm hoping to see some change each week. I have noticed when I put URL's starting with https:// in to the removal tool, it adds the http:// main URL at the front. For example, I add to the removal tool:- https://www.mydomain.com/blah.html?search_garbage_url_addition On the confirmation page, the URL actually shows as:- http://www.mydomain.com/https://www.mydomain.com/blah.html?search_garbage_url_addition I don't want to accidentally remove my main URL or cause problems. Is this the right way this should look? AND PART 2 OF MY QUESTION If you see the search description in Google for a page you want removed that says the following in the SERP results, should I still go to the trouble of putting in the removal request? www.domain.com/url.html?xsearch_... A description for this result is not available because of this site's robots.txt – learn more.

              Technical SEO | Jul 9, 2014, 6:27 AM | sparrowdog
              1
            • allstatetransmission

              Removing images from site and Image Sitemap SEO advice

              Hello again, I have received an update request where they want me to remove images from this site (as of now its a bunch of thumbnails) current page design: http://1stimpressions.com/portfolio/car-wraps/ and turn it into a new design which utilized a slider (such as this): http://1stimpressions.com/portfolio/ They don't want the thumbnails on the page anymore. My question is since my site has a image sitemap that has been indexed will removing all the images hurt my SEO greatly? What would the recommended steps to take to reduce any SEO damage be, if so? Thank you again for your help, always great and very helpful feedback! 🙂 cheers!

              Technical SEO | Nov 7, 2013, 2:24 PM | allstatetransmission
              0
            • RyanOD

              Removing Redirected URLs from XML Sitemap

              If I'm updating a URL and 301 redirecting the old URL to the new URL, Google recommends I remove the old URL from our XML sitemap and add the new URL. That makes sense. However, can anyone speak to how Google transfers the ranking value (link value) from the old URL to the new URL? My suspicion is this happens outside the sitemap. If Google already has the old URL indexed, the next time it crawls that URL, Googlebot discovers the 301 redirect and that starts the process of URL value transfer. I guess my question revolves around whether removing the old URL (or the timing of the removal) from the sitemap can impact Googlebot's transfer of the old URL value to the new URL.

              Technical SEO | May 5, 2021, 4:56 AM | RyanOD
              0
            • Wallander

              Removing robots.txt on WordPress site problem

              Hi..am a little confused since I ticked the box in WordPress to allow search engines to now crawl my site (previously asked for them not to) but Google webmaster tools is telling me I still have robots.txt blocking them so am unable to submit the sitemap. Checked source code and the robots instruction has gone so a little lost. Any ideas please?

              Technical SEO | Mar 21, 2013, 12:50 PM | Wallander
              0
            • AndrewAkesson

              Web config redirects not working where a trailing slash is involved

              I'm having real trouble with getting working redirects in place to use on a site we're re-launching with a modified url structure. Old URL: http://www.example.com/example_folder/ New URL: http://www.example.com/example-of-new-folder/ Now, where the old URL's have a trailing slash the web.config simply will not accept it. It says the URL can start with a slash, but not end with a slash. However, many of my URL's do end with a slash so I need a workaround. These are the rules I'm putting in place: <location path="example_folder/"></location> Thanks

              Technical SEO | Mar 26, 2012, 10:55 AM | AndrewAkesson
              0
            • amit.ganguly

              How to remove the 4XX Client error,Too many links in a single page Warning and Cannonical Notices.

              Firstly,I am getting around 12 Errors in the category 4xx Client error. The description says that this is either bad or a broken link.How can I repair this ? Secondly, I am getting lots of warnings related to too many page links of a single page.I want to know how to tackle this ? Finally, I don't understand the basics of Cannonical notices.I have around 12 notices of this kind which I want to remove too. Please help me out in this regard. Thank you beforehand. Amit Ganguly http://aamthoughts.blogspot.com   - Sustainable Sphere

              Technical SEO | Jun 19, 2012, 11:25 AM | amit.ganguly
              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.