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
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
-
A Sitemap Web page & A Sitemap in htaccess - will a website be penalised for having both?
Hi I have a sitemap url already generated by SEO Yoast in the htaccess file, and I have submitted that to the search engines. I'd already created a sitemap web page on the website, also as a helpful aid for users to see a list of all page urls. Is this a problem and could this scenario create duplicate issues or any problems with search engines? Thanks.
White Hat / Black Hat SEO | | SEOguy10 -
On the use of Disavow tool / Have I done it correctly, or what's wrong with my perception?
On a site I used GSA search engine ranker. Now, I got good links out of it. But, also got 4900 links from one domain. And, I thought according to ahrefs. One link from the one domain is equal to 4900 links from one domain. So, I downloaded links those 4900 and added 4899 links to disavow tool. To disavow, to keep my site stable at rankings and safe from any future penalty. Is that a correct way to try disavow tool? The site rankings are as it is.
White Hat / Black Hat SEO | | AMTrends0 -
One guy using some Alexa rank tricks to gain high PR etc..?
Hi! One finnish guy is getting pretty nice Alexa ranking to his sites, even if the real traffic is not somewhere near it would lead for that cool Alexa rank. I am a bit suspisious if he is using some Low Bounce Rate High Traffic Boosters on his sites.. I will give you some examples here to look into.. Vihjepaikka(dot)com - Created on 2013-03-13 - Alexa Rank 129k!!! - PR3 - Backlinks not many qualitys.. Casinolla(dot)net - Created on 2014-10-15 - Alexa Rank 351k!!! - PR0 - Backlinks 0!!! Cashadvance777(dot)com - Created on 2014-09-04 - Alexa Rank 772k!!! - PR3 - Backlinks 0!!! Let me know your thoughts on these.. Cheers!
White Hat / Black Hat SEO | | Kononen0 -
What EMD Meta Title should we use and what about getting links to the same C-Block IP?
Situation: Recently I encountered two problems with both internal and external SEO for my company websites.
White Hat / Black Hat SEO | | TT_Vakantiehuizen
This Dutch company has four websites on one server. Three closely related EMD(Exact Match Domain) websites and one overarching website. (Holiday homes rental websites) Vakantiehuizen-Verhuur.nl (overarching)
Vakantiehuizen-Frankrijk.nl (EMD)
Vakantiehuizen-Italie.nl (EMD)
Vakantiehuizen-Spanje.nl (EMD) Question 1:
What would be a preferable Meta Title for the EMD websites (homepage/subpages)? Keep in mind that the domains are EMD. The homepage will target the most important keywords and should not compete with subpages. Options for the homepage:
1. Vakantiehuizen Frankrijk | Alle vakantiehuizen in Frankrijk op een rij!
2. Vakantiehuizen Frankrijk | Vakantiehuizen-Frankrijk.nl onderdeel van Vakantiehuizen-Verhuur.nl
3. Suggestions? Options for the subpages:
1. Vakantiehuis Normandie | Vakantiehuizen Frankrijk
2. Vakantiehuis Normandie | Vakantiehuizen-Frankrijk.nl
3. Suggestions? And concerning the keywords in the beginning; is it wise to use both plural and singular terms in the meta title? For Example:
Hotel New York. Best hotels in New York | Company Name Question 2: Many SEOs state that getting (too many) links from the same C-Block IP is bad practice and should be avoided. Is this also applicable if one website links out to different websites with the same C-Block IP? Thus, website A, B and C (on the same server) link to website D (different server) could be seen as spam but is this the same when website D links to website A, B and C?0 -
URL structure: 301 redirect or leave as is?
Hello, My website, www.coloringbookfun.com is very old and authoritative, but the URL structure is terrible. If you check out some of our subcategories such as http://www.coloringbookfun.com/Kung Fu Panda and individual printables such as http://www.coloringbookfun.com/Kung Fu Panda/imagepages/image2.html You can see that they aren't optimized. I am curious to know the pros and cons of fixing the URL structure and 301ing them to the new optimized url. Will 301ing lose authority and backlinks for the sites pages? Does optimizing the url structure outweigh losing the authority/backlinks?
White Hat / Black Hat SEO | | WebServiceConsulting.com0 -
Which links should I remove?
What is your general approach when removing links for a new client? Just taken on some new work and found links that I wouldn't dream of building now (unrelated domain name, blogroll, single word, exact match anchor, dead sites). However some of these are brand anchor links, and some of the pages have decent Page Rank (2/3/4). Obviously I don't want to remove links that might actually be helping the site in a weird way. It would be good to get an idea of other peoples approach to link removal - what goes, what stays etc?
White Hat / Black Hat SEO | | Coolpink0 -
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 -
Use of 301 redirects
Scenario Dynamic page produces great results for the user but produces a long very un-user and un-search friendly URL http://www.OURSITE.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=loving&x=0&y=0#/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=lovingthebead&rh=i%3Aaps%2Ck%3Alovingthebead Solution 301 redirect in .htaccess Fantastic - works a treat BUT after redirect the original long ugly old URL appears in the location field Would really like this showing the new short user friendly short URL What am I doing wrong? Thank you all. CB
White Hat / Black Hat SEO | | GeezerG0