How to remove trailing slashes in URLs using .htaccess (Apache)?
-
I want my URLs to look like these:
http://www.domain.com/buy/shoes
http://www.domain.com/buy/shoes/red
Thanks in advance!
-
I am sorry my friend. Somehow I missed your response.
It should have been: RewriteRule ^(.*)/$ /$1 [R,L]
So, you missed the /
And it is also used to remove the trailing slash from URLs just like the one that I gave you earlier.
Best,
Devanur Rafi
-
And what is the difference of this to the one you've answered?
RewriteBase /
RewriteRule ^(.*)/$ $1 [R,L] -
Thanks Devanur! Big help. By the way, I'm still looking for an opinion about this and I'm sure you can help me with this issue:http://moz.com/community/q/how-can-i-301-redirect-a-series-of-pages-ex-page-1-page-2-page-3-to-one-landing-page-new-url
-
Hi, here you go.....
RewriteRule ^(.)/(?.)?$ $1$2 [R=301,L]
Please note that the thing which looks like a capital V in the above rule is actually the backward slash and forward slash together.
Best,
Devanur Rafi
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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.
Related Questions
-
I have 100+ Landing Pages I use for PPC... Does Google see this as a blog farm?
I am currently using about 50-100 domains for geotargeted landing pages for my PPC campaigns. All these pages basically have the same content, I believe are hosted on a single unique ip address and all have links back to my main url. I am not using these pages for SEO at all, as I know they will never achieve any significant SEO value. They are simply designed to generate a higher conversion rate for my PPC campaigns, because they are state and city domains. My question is, does google see this as a blog/link farm, and if so, what should I do about it? I don't want to lose any potential rankings they may be giving my site, if any at all, but if they are hurting my main urls SEO performance, then I want to know what I should do about it. any advice would be much appreciated!
White Hat / Black Hat SEO | | jfishe19881 -
Canonical tag On Each Page With Same Page URL - Its Harmful For SEO or Not?
Hi. I have an e-commerce project and they have canonical code in each and every page for it's own URL. (Canonical on Original Page No duplicate page) The url of my wesite is like this: "https://www.website.com/products/produt1"
White Hat / Black Hat SEO | | HuptechWebseo
and the site is having canonical code like this: " This is occurring in each and every products as well as every pages of my website. Now, my question is that "is it harmful for the SEO?" Or "should I remove this tags from all pages?" Is that any benefit for using the canonical tag for the same URL (Original URL)?0 -
Googlebot crawling AJAX website not always uses _escaped_fragment_
Hi, I started to investigate googlebot crawl log of our website, and it appears that there is no 1:1 correlation between a crawled URL with escaped_fragment and without it.
White Hat / Black Hat SEO | | yohayg
My expectation is that each time that google crawls a URL, a minute or so after, it suppose to crawl the same URL using an escaped_fragment For example:
Googlebot crawl log for https://my_web_site/some_slug Results:
Googlebot crawled this URL 17 times in July: http://i.imgur.com/sA141O0.jpg Googlebot crawled this URL additional 3 crawls using the escaped_fragment: http://i.imgur.com/sOQjyPU.jpg Do you have any idea if this behavior is normal? Thanks, Yohay sOQjyPU.jpg sA141O0.jpg0 -
I have a recipe food blog and use wordpress, but my recipes are usually in more than one category...?
The recipes are in most cases in more than one category (usually two) each. Do and (and if so how) need to set each post to one canicol url? E.g A recipe on Peas is in healthy foods (which is the default wordpress cat.) and also Vegetarian Dishes. I use YOAST for wordpress
White Hat / Black Hat SEO | | Kelly33300 -
What is the difference between using .htaccess file and httpd.conf in implementing thousands of 301 redirections?
What is the best solution in terms of website loading time or server load? Thanks in advance!
White Hat / Black Hat SEO | | esiow20130 -
Using competitor brand names. How far is too far?
We are a small company competing for traffic in an industry with more or less one other very large brand. I'm noticing we are getting a descent amount of organic traffic for the competitor's brand name however I haven't done any on-page inclusion or link building for the term. We are using their brand as a keyword in our paid campaigns and seeing potential. I firmly believe we have a superior product. I'm tempted to start going after our competitor's brand as a keyword to skim some of their traffic. My question is how far it too far? Do I actively try to obtain a few anchor text specific backlinks? Dare I use their brand name as a term on our page? Maybe just a simple blog post comparing our two products is more appropriate? Any suggestions are appreciated.
White Hat / Black Hat SEO | | CaliB0 -
Link Removal and Disavow - Is Page Rank a sign directory is okay with Google
Hi, Currently cleaning up a clients link profile in preparation for disavow file and I have reached the stage where I am undecided on some directories as I don't want to remove all links. Is Page Rank an indication that Google is okay with a particular directory? For example the following domain is questionable, but has a PR of 3. Do I need to consider scrapping all such links in anticipation of future updates? http://www.easyfinddirectory.com/shopping-and-services/clothing http://www.toplocallistings.co.uk/Apparel/West_Midlands/Shropshire/ Thanks in advance Andy
White Hat / Black Hat SEO | | MarzVentures0 -
Link Building using Badges
In light of penguin update, is link building using badges(like "I love SEOMOZ" badge) still considered a white hat tactic? I have read old posts on SEOMOZ blog about this topic and wondering if this method is still effective. Look forward to feedback from MOZers.
White Hat / Black Hat SEO | | Amjath0