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
-
My indexed site URL removed from google search without get any message or Manual Actions???
On Agust 2 or 3.. I'm not sure about the exact date...
White Hat / Black Hat SEO | | newwaves
The main URL of my website https://new-waves.net/ had been completely removed from Google search results! without getting any messages or Manual Actions on search console ?? but I'm still can find some of my site subpages in search results and on Google local maps results when I tried to check it on google
info:new-waves.net >> no results
site:new-waves.net >> only now I can see the main URL in results because I had submitted it again and again to google but it might be deleted again today or tomorrow as that happen before last few days
100% of all ranked keywords >> my site URL new-waves.net had been completely removed from all results! but I'm still can see it on maps on some results I never get any penalties to my site on Google search console. I noticed some drops on some keywords before that happens (in June and July) but it all of it was related to web design keywords for local Qatar, but all other keywords that related to SEO and digital marketing were not have any changes and been on top My site was ranked number 1 on google search results for "digital marketing qatar" and some other keywords, but the main URL had been removed from 100% of all search results. but you can still see it on the map only. I just tried to submit it again to Google and to index it through google search console tool but still not get any results, Recently, based on google console, I found some new links but I have no idea how it been added to links of my website:
essay-writing-hub.com - 9,710
tiverton-market.co.uk - 252
facianohaircare.com - 48
prothemes.biz - 44
worldone.pw - 2
slashdot.org - 1
onwebmarketing.com - 1 the problem is that all my high PR real links deleted from google console as well although it still have my site link and it could be recognized by MOZ and other sites! Can any one help to know what is the reason?? and how can I solve this issue without losing my previous ranked keywords? Can I submit a direct message to google support or customer service to know the reason or get help on this issue? Thanks & Regards0 -
I'm changing title tags and meta tags, url, will i loose my ranking?
Hi Guys QUESTION: I'm currently going through a re-design for my new website that was published in November 2014 - since launching we found there were many things we needed to change, our pages were content thin being one of the biggest. I had industry experts that came in and made comments on the title tags lacking relevance for eg: our title tag for our home page is currently "Psychic Advice" most ideal customers don't search "Psychic Advice" they search more like "Online Psychic Reading" or Psychic Readings" I noticed alot of my competitors also were using title tags such as Online Psychic Readings, Free Psychic Readings etc so it brings me to my question of "changing the title tags around. The issue is, im ranking for two keywords in my industry, online psychics and online psychic readings in NZ. 1. Our home page and category pages are content thin.... so hoping that adding the changes will create perhaps some consistency also with the added unique and quality content. Here is the current website: zenory. co.nz and the new one is www.ew-zenory.herokuapp.com which is currently in development I have 3 top level domains com,com.au, and co.nz Is there anyone that can give me an idea if I were to change my home page title tag to **ZENORY | Online Psychic Readings | Live Psychic Phone and Chat ** If this will push my rankings down though this page will have alot more valuable content etc? For obvious reasons im going to guess it will make drop, I'm wondering though if it is worth changing the title tags and meta descriptions around or leaving it as is if its already doing well? How much of a difference do title tags and meta descriptions really make? Any insight into this would be great! Thanks
White Hat / Black Hat SEO | | edward-may1 -
One page with multiple sections - unique URL for each section
Hi All, This is my first time posting to the Moz community, so forgive me if I make any silly mistakes. A little background: I run a website that for a company that makes custom parts out of specialty materials. One of my strategies is to make high quality content about all areas of these specialty materials to attract potential customers - pretty strait-forward stuff. I have always struggled with how to structure my content; from a usability point of view, I like just having one page for each material, with different subsections covering covering different topical areas. Example: for a special metal material I would have one page with subsections about the mechanical properties, thermal properties, available types, common applications, etc. Basically how Wikipedia organizes its content. I do not have a large amount of content for each section, but as a whole it makes one nice cohesive page for each material. I do use H tags to show the specific sections on the page, but I am wondering if it may be better to have one page dedicated to the specific material properties, one page dedicated to specific applications, and one page dedicated to available types. What are the communities thoughts on this? As a user of the website, I would rather have all of the information on a single, well organized page for each material. But what do SEO best practices have to say about this? My last thought would be to create a hybrid website (I don't know the proper term). Have a look at these examples from Time and Quartz. When you are viewing a article, the URL is unique to that page. However, when you scroll to the bottom of the article, you can keep on scrolling into the next article, with a new unique URL - all without clicking through to another page. I could see this technique being ideal for a good web experience while still allowing me to optimize my content for more specific topics/keywords. If I used this technique with the Canonical tag would I then get the best of both worlds? Let me know your thoughts! Thank you for the help!
White Hat / Black Hat SEO | | jaspercurry0 -
How should I use the 2nd link if a site allows 2 in the body of a guest post?
I've been doing some guest posting, and some sites allow one link, others allow more. I'm worried I might be getting too many guest posts with multiple links. I'd appreciate your thoughts on the following: 1. If there are 50+ guest posts going to my website (posted over the span of several months), each with 2 links pointing back only to my site is that too much of a pattern? How would you use the 2nd link in a guest post if not to link to your own site? 2. Does linking to .edu or .gov in the guest post make the post more valuable in terms of SEO? Some people recommend using the 2nd link to do this. Thanks!
White Hat / Black Hat SEO | | pbhatt0 -
Solved PayDay hack - but SERPs show URLs - what should I do?
We had the PayDay hack - and solved it completely. The problem is - the SERPs have over 3,000 URLs pointing to 404 on our website all of which have urls that are like this: <cite>www.onssi.com/2012/2/post1639/payday-loan-companies-us</cite> What should I do? Should I disavow every one of the 3,000? No Follow?
White Hat / Black Hat SEO | | Ocularis0 -
Need advice on best strategy for removing these bad links.
Heres the scenario... We recently took on a new client who's previous seo company had partaken in some dodgy link building tactics. They appear to have done some blog comment spam, very poorly. The situation we are now in is this: We have a site with an internal page deemed more important than the homepage (the homepage has 60 linking root domains and the internal page 879). It looks as though the previous seo company submitted a disavow request, theres a message in webmaster tools from a few weeks back saying it had been received, but no further correspondence. I have doubts as to whether this disavow request was done correctly... Plus im not sure that Google has issued the site a warning yet as they are ranking position one for the keyword on the internal page. Our clients want us to handle this in the correct manner, whether it be to simply ignore it and wait for Google to send a warning about the links, remove the offending internal page and leave a 404, or try to disavow the links that google doesnt know about yet from 800+ websites. Suggestions for the best practice for dealing with this situation? Any advice is much appreciated, Thanks, Hayley.
White Hat / Black Hat SEO | | Silkstream0 -
Is it worthwhile to remove a large quantity of lesser quality links if you are able to do so easily?
So I've recently started working at a new company where I lead up their SEO efforts. In regards to link building I've discovered that a little over 75% of the anchor text on the links to the homepage (at least of the 10k SEOmoz provides) are non branded keywords. We don't appear to have any penalties, however, in my opinion we have what is an unnatural link profile for our homepage. As I investigated further I've noticed that a lot of these links (not all) are from irrelevant blogs where the link is found in the footer. (Clearly this was the result of some less than ideal get links quick strategy that was implemented in the past.) At first I was overwhelmed thinking that I'd have to try and contact these sites individually to see if I could get the link removed, however, I soon discovered that the site these links are actually linking to is not our domain, but is instead a domain that redirects to our site. So this brings me to my question: Should I remove the redirect from this other site to rid myself of these links. The white hat side of me strongly thinks this is a good step forward, however, a small part of me wonders what the ramifications would be. These types of redirects seem to account for a fairly high number of links, however what value that actually contribute is difficult to know. Any thoughts?
White Hat / Black Hat SEO | | Poindexter0