NGinx rule for redirecting trailing '/'
-
We have successfully implemented run-of-the-mill 301s from old URLs to new (there were about 3,000 products). As normal. Like we do on every other site etc.
However, recently search console has started to report a number of 404s with the page names with a trailing forward slash at the end of the .html suffix.
So, /old-url.html is redirecting (301) to /new-url.html
However, now for some reason /old-url.html/ has 'popped up' in the Search Console crawl report as a 404.
Is there a 'blobal' rule you can write in nGinx to say redirect *.html/ to */html (without the forward slash) rather than manually doing them all?
-
Hi there.
Yes, the global rule should work. However, there is a reason this is happening, and it look like there is an extra rule, which adds that trailing slash. Go through those new rules you've added, make sure that you don't have anything extra. Example might be "Redirect everything from old blog to new blog with adding trailing slash" or something. It's quite common error, so you should be able to figure it out.
Also see when these 404s were discovered, if it was right after you did redirects, it means for sure, that some of the new redirect rules are messed up at some point.
Cheers!
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
-
Would You Redirect a Page if the Parent Page was Redirected?
Hi everyone! Let's use this as an example URL: https://www.example.com/marvel/avengers/hulk/ We have done a 301 redirect for the "Avengers" page to another page on the site. Sibling pages of the "Hulk" page live off "marvel" now (ex: /marvel/thor/ and /marvel/iron-man/). Is there any benefit in doing a 301 for the "Hulk" page to live at /marvel/hulk/ like it's sibling pages? Is there any harm long-term in leaving the "Hulk" page under a permanently redirected page? Thank you! Matt
Intermediate & Advanced SEO | | amag0 -
Redirecting an IP address
Just taken over a new client who recently moved from A.N. other platform to Shopify. I just found reference to their old website IP address and it appears to be not redirecting. Can I simply use something like Traffic Control (Shopify app) to redirect to the new domain?
Intermediate & Advanced SEO | | muzzmoz0 -
Putting my content under domain.com/content, or under related categories: domain.com/bikes/content ?
Hello This questions plays on what Joe Hall talked about during this years' MozCon: Rethinking Information Architecture for SEO and Content Marketing. My Case:
Intermediate & Advanced SEO | | Inevo
So.. we're working out guidelines and templates for a costumer (sporting goods store) on how to publish content (articles, videos, guides) on their category pages, product pages, and other pages. At this moment I have 2 choices:
1. Use a url-structure/information architecture where all the content is placed in one subfolder, for example domain.com/content. Although it's placed here, there's gonna be extensive internal linking from /content to the related category pages, so the content about bikes (even if it's placed under domain.com/bikes) will be just as visible on the pages related to bikes. 2. Place the content about bikes on a subdirectory under the bike category, **for example domain.com/bikes/content. ** The UX/interface for these two scenarios will be identical, but the directories/folder-hierarchy/url structure will be different. According to Joe Hall, the latter scenario will build up more topical authority and relevance towards the category/topic, and should be the overall most ideal setup. Any thoughts on which of the two solutions is the most ideal? PS: There is one critical caveat her: my costumer uses many url-slugs subdirectories for their categories, for example domain.com/activity/summer/bikes/, which means the content in the first scenario will be 4 steps away from the home page. Is this gonna be a problem? Looking forward to your thoughts 🙂 Sigurd, INEVO0 -
Sitemaps: HTML and/or XML?
Can someone explain sitemaps, and if you need html and/or xml? I have a site with a few html sitemaps, one for products, one for categories. I have another site with just one xml sitemap for my entire site (which has massive pages, 600k+). Should I be dividing the site with massive pages into html sitemaps like my other site?
Intermediate & Advanced SEO | | WebServiceConsulting.com0 -
Effect SERP's internal 301 redirects?
I'm considering installing Wordpress for my website. So I have to change the static URL's from /webpage.html to /webpage/. Yet I don't want to lose in the SERP's. What should I expect?
Intermediate & Advanced SEO | | wellnesswooz1 -
301 redirect w/ dynamic pages to static
I am trying to redirect old dynamically created pages to a new static one (single page). However, when I implement the redirects, it still uses part of the old dynamic url. For instance... dynamic.php?var=example1 dynamic.php?var=example2 dynamic.php?var=example3 should all redirect to: static.html. However, they are redirecting to: static.html?var=example1 static.html?var=example2 static.html?var=example3 The page is resolving fine, but I don't want google to misinterpret the new static page as numerous page with dup content. I tried this in PHP on the dynamic.php page as follows, but it the problem above persisted: header('HTTP/1.1 301 Moved Permanently');
Intermediate & Advanced SEO | | TheDude
header('Location: http://www.mysite.com/static.html'); I tried doing it in my .htaccess file as follows, but the problem persisted: redirect 301 /info/tool_stimulus.php?var=example1 http://www.mysite.com/static.html
redirect 301 /dynamic.php?var=example2 http://www.mysite.com/static.html Can anyone solve this in PHP or w/ htaccess? Help!!! 🙂0 -
E-Commerce site - How do I geo-target towns/cities/states if there aren't any store locations?
Site = e-commerce Products = clothing (no apparel can be location specific like sports gear where you can do the location specific team gear (NBA, NFL, etc)) Problems = a. no store front b. I don't want to do any sitewides (footers, sidebars, etc) because of the penguin update Question = How do you geo-target these category pages and product pages? Ideas = a. reviews with clients locations b. blog posts with clients images wearing apparel and location description and keywords that also links back to that category or be it product page (images geo- targeted, tags, and description) c. ? Thanks in advance!
Intermediate & Advanced SEO | | Cyclone0 -
Redirect
Hi, I have one domain which was redirected today (the main domain,root) was redirected to a new subdomain of the main root domain.site was ranking for several keywords and had an authority of 35 on root domain. Site after 12 hours disappeared from google results.dont even rank for its brand name. What will happened to the new subdomain? Will rank again? Have the same keywords plus some more.old keywords are 3 and new are 2. For the old keywords on page optimization gets a c , and for the new a+c. For the new keywords don't have backlinks at all. When my site will start to rank for its old keywords? How long will be down ? Will pass the link juice and authority? If yes how soon ? Because I will loose to much money if stay longer like 1-2 weeks down. Thanks
Intermediate & Advanced SEO | | nyanainc0