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
-
Site build in the 80% of canonical URLs - What is the impact on visibility?
Hey Everyone, I represent international wall decorations store where customer can freely choose a pattern to be printed on a given material among a few milions of patterns. Due to extreme large number of potential URL combinations we struggle with too many URL adressess for a months now (search console notifications). So we finally decided to reduce amount of products with canonical tag. Basing on users behavior, our business needs and monthly search volume data we selected 8 most representative out of 40 product categories and made them canonical toward the rest. For example: If we chose 'Canvas prints' as our main product category, then every 'Framed canvas' product URL points rel=canonical tag toward its equivalent URL within 'Canvas prints' category. We applied the same logic to other categories (so "Vinyl wall mural - Wild horses running" URL points rel=canonical tag to "Wall mural - Wild horses running" URL, etc). In terms of Googlebot interpretation, there are really tiny differences between those Product URLs, so merging them with rel=canonical seems like a valid use. But we need to keep those canonicalised URLs for users needs, so we can`t remove them from a store as well as noindex does not seem like an good option. However we`re concerned about our SEO visibility - if we make those changes, our site will consist of ~80% canonical URLs (47,5/60 millions). Regarding your experience, do you have advices how should we handle that issue? Regards
White Hat / Black Hat SEO | | _JediMindBender
JMB0 -
Homepage not ranking for branded searches after Google penalty removal
Hi all, A site I work on was hit with a manual action penalty some time ago for spammy links built by a former SEO agency. It was a partial match penalty so only affected some pages - most likely the homepage. We carried out a lot of work cleaning up links and disavowed suspicious links which we couldn't get removed. Again, most of these were to the homepage. The disavow file was uploaded to Google last Friday and our penalty was lifted this Tuesday. Since uploading the disavow file, our homepage does not show up at all for branded searches. I've carried out the obvious checks - robots.txt, making sure we're not accidentally noindexing the page or doing anything funky with canonicals etc and it's all good. Have any of you guys had a similar experience? I'm thinking Google simply needs time to catch up due to all the links we've disavowed and sitting tight is the best option but could do with some reassurance! Any past experiences or advice on what I might be missing would be great. Thanks in advance, Brendan.
White Hat / Black Hat SEO | | Brendan-Jackson1 -
Magento Category URL
Hello I do SEO consulting and a client launch a new Magento Enterprise site. My question is they changed a URL from /category-list/ to /category/ and it is 301 redirecting correctly but the links off of that URL are not. Example: www.site.com/category/ if you click a link the next one shows up like this: www.site.com/categorty-list/vendor/ for example. Any help would be appreciated! Thanks
White Hat / Black Hat SEO | | christaylorconsulting0 -
Suggestions in redirecting an old URL to new URL with parenthesis () ?
What should I use in .htaccess if I will redirect an old URL with parentheses to a new URL like below? RedirectMatch 301 http://www.olddomain.com/buy/nike-shoes/kobe(7)/red http://www.newdomain.com/buy/nike-shoes/kobe(7)/red Or RedirectMatch 301 http://www.olddomain.com/buy/nike-shoes/kobe(7)/red http://www.newdomain.com/buy/nike-shoes/kobe(7)/red
White Hat / Black Hat SEO | | esiow20130 -
Competitors using unsavoury methods of link building. How to combat?
A lot of my competitors are using a lot of unsavoury/old-fashioned SEO methods to build links but are actually doing really well from it. A few different competitors are buying links in directories, using blogspam comments, forum posts, buying links in other places. The problem is, they all seem to be doing very well with it! What I've always been taught is that these methods are out and they could actually harm you - yet I haven't seen this happen to my competitors. Should I be using these spammy methods too or just concentrate on building quality content and high quality link building?
White Hat / Black Hat SEO | | charliedouglas1230 -
SEO best practice: Use tags for SEO purpose? To add or not to add to Sitemap?
Hi Moz community, New to the Moz community and hopefully first post/comment of many to come. I am somewhat new to the industry and have a question that I would like to ask and get your opinions on. It is most likely something that is a very simple answer, but here goes: I have a website that is for a local moving company (so small amounts of traffic and very few pages) that was built on Wordpress... I was told when I first started that I should create tags for some of the cities serviced in the area. I did so and tagged the first blog post to each tag. Turned out to be about 12-15 tags, which in turn created 12-15 additional pages. These tags are listed in the footer area of each page. There are less than 20 pages in the website excluding the tags. Now, I know that each of these pages are showing as duplicate content. To me, this just does not seem like best practices to me. For someone quite new to the industry, what would you suggest I do in order to best deal with this situation. Should I even keep the tags? Should I keep and not index? Should I add/remove from site map? Thanks in advance for any help and I look forward to being a long time member of SEOMoz.
White Hat / Black Hat SEO | | BWrightTLM0 -
Is it okay to use hiddencontaining meta information that is a video transcript?
I have been using the tools at DotSub.com to transcribe our YouTube videos. They are free, work really great and I highly recommend them. Today I received an email from DotSub with recommendations for SEO on video. I have a question about #5 on their list. Here it is: "Step 5: Embed the video transcript into the non-visible meta-data of the page" "Always embed the video transcript in the page meta-data This is done by placing
White Hat / Black Hat SEO | | danatanseo
the content of the transcription within a non-visible HTML element (a hidden
div). While most search engines do not weight non-visible content as high as
visible content, this will still provide additional SEO for your page. Do
this whether you include the full transcript visibly on your page or not." This is something I have never heard before. And, like many of you, I have always heard that putting anything "hidden" in the HTML is a very bad idea. Is this different? Do any of you do this? Is it really a recommended technique? Thanks all! Dana0 -
Google Bombing For A Specific URL
The term "Beruk" which means "Ape or Monkey" in english brings up this page of wikipedia amongst the first page result: URL: http://en.wikipedia.org/wiki/Khairy_Jamaluddin The page does not contain the word "Beruk". External links to the page do not contact the anchor-text "Beruk" Given the above scenario, how is the page still ranking on first page for this keyword?
White Hat / Black Hat SEO | | rajeevbala0