Moz Q&A is closed.
After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.
301 Redirect "wildcard" question
- 
					
					
					
					
 I have been looking at the SEOmoz redirect guide for some advice but I can't seem to find the answer : http://www.seomoz.org/learn-seo/redirection I have lots of URLs from a previous version of a site that look like the following: etc etc. I want to write a redirect so whenever a URL with the terms "-c-25.html" is requested it redirects to a specified page, regardless of what comes after the question mark. These URLs were created by our previous ecommerce software. The 'c' is for category, and each page of the cateogry created a different URL. I want to do these so I can rediect all of these URLs to the appropraite new cateogry page in a single redirect. Thanks for any help. 
- 
					
					
					
					
 When I did a similar transition with hundreds of thousands of links. I created a database table with source and destination columns. Then a script that handles all 404 requests. If the requested link matches an entry in the source column, the user is sent a 301 to the matching destination entry. That allowed for easier maintenance than a huge htaccess file and the server load caused by te script should go down over time as 301 are saved and you contact site owners to update links. The other benefit is that you can do enhanced tracking to see what is request, found and not found and where those people came from. 
- 
					
					
					
					
 An easy way is to use RedirectMatch, example: RedirectMatch 301 /-c-25.html http://www.domain.com/new-category Drop the above in a .htaccess file, test it works how you expect first  
- 
					
					
					
					
 OK, If I make it the first redirect then the redirection works - regardless of what is written after the 'c-21.html'. However the redirect is retaining the erroneous URL data after redirection. It is adding the '?blahblahblah" to the end of the new URL. I want it to dispose of this so all the redirects are routed to just one URL. How do I instruct it to not include this unwanted data in the new URL? Thanks 
- 
					
					
					
					
 Order matters in Rewrites. You will have to place that Rewrite Rule above the others. 
- 
					
					
					
					
 I thought that may do it but still nothing. Maybe I am entering it wrong? Here is the code in .htaccess: RewriteEngine On RewriteBase /test/ RewriteRule ^index.php$ - [L ]RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /test/index.php [L] RewriteRule ^-c-21.html(.*)$ http://www.mysitename.com/test/category/t-shirts/dolphin_tshirts [R=301,L ] The redirect just doesn't happen. EDIT: If I write a standard redirect : Redirect 301 /test/-c-21.html then it will redirect to the desired page but it will retain the ?blahblah and add it to the new URL. I want it to work like this but discard the ?blahblahblah after redirecting. 
- 
					
					
					
					
 If you need these to be 301 redirects... RewriteRule ^-c-25.html(.*)$ http://www.yoursite.com/dolphin_tshirts [R=301,L] 
- 
					
					
					
					
 Just to calrify I need a URL that has /-c-25.html?blahblahblah to change to: /dolphin_tshirts Regardless of that is written in the blahblahblah part. 
- 
					
					
					
					
 I think that would probably work for him, assuming that the category IDs remain the same. 
- 
					
					
					
					
 Would something liek this work: RewriteRule ^-c-(.).html(.)$ category/$1.html$2 [R,NC] I've not tested it, nor do I claim to be an expert, but I think it will work for what you're tryign to acheive - e.g. -c-25.html becomes category/25.html 
- 
					
					
					
					
 If your site is in PHP, you could simply add the code... $targetURL = "http://www.sitename.com/whatever-page-you-what"; if(stristr($_SERVER['REQUEST_URI'],"-c-25.html")) { header("HTTP/1.1 301 Moved Permanently"); header("Location: $targetURL"); } ?> If you don't have access to PHP, you could add a line like this to your HTACCESS file... RewriteCond %{THE_REQUEST} (c-25.html) [NC] 
 RewriteRule .* http://www.sitename.com/your-target-page [L,R=301]Someone might want to double check me on that rewriteRule above, though. 
Browse Questions
Explore more categories
- 
		
		Moz ToolsChat with the community about the Moz tools. 
- 
		
		SEO TacticsDiscuss the SEO process with fellow marketers 
- 
		
		CommunityDiscuss industry events, jobs, and news! 
- 
		
		Digital MarketingChat about tactics outside of SEO 
- 
		
		Research & TrendsDive into research and trends in the search industry. 
- 
		
		SupportConnect on product support and feature requests. 
Related Questions
- 
		
		
		
		
		
		301 Redirects, Sitemaps and Indexing - How to hide redirected urls from search engines?
 We have several pages in our site like this one, http://www.spectralink.com/solutions, which redirect to deeper page, http://www.spectralink.com/solutions/work-smarter-not-harder. Both urls are listed in the sitemap and both pages are being indexed. Should we remove those redirecting pages from the site map? Should we prevent the redirecting url from being indexed? If so, what's the best way to do that? Technical SEO | | HeroDesignStudio0
- 
		
		
		
		
		
		301 Redirect non existant pages
 Hi I have 100's of URL's appearing in Search Console for example: ?p=1_1 These go to on to 5_200 etc.. I have tried to do htaccess and the mod rewrite is on as I can redirect directories to the root i.e RewriteRule ^web_example(.*)$ /$1 [R=301,N,L] However I have tried all kinds of variations to redirect ?p= and either it doesn't work at all or it crashes the website. Can anyone point me in the right direction to fix this. Technical SEO | | Cocoonfxmedia0
- 
		
		
		
		
		
		301 redirect relative or absolute path?
 Hello everyone, Recently we've changed the URL structure on our website, and of course we had to 301 redirect the old urls to the coresponding new ones. The way the technical guys did this is: "http://www.domain.com/old-url.html" 301 redirect to "/new-url.html" Technical SEO | | Silviu
 meaning as a relative redirect path, not an absolute one like this:
 "http://www.domain.com/old-url.html" 301 redirect to "http://www.domain.com/new-url.html" This happened for few thousands urls, and the fact is the organic traffic dropped for those pages after this change. (no other changes were made on these pages and the new urls are as seo friendly as possible, A grade on On-Page Grader). The question is: does the relative redirect negatively affects seo, or it counts the same as an absolute path redirect? Thanks,
 S.0
- 
		
		
		
		
		
		"Fourth-level" subdomains. Any negative impact compared with regular "third-level" subdomains?
 Hey moz New client has a site that uses: subdomains ("third-level" stuff like location.business.com) and; "fourth-level" subdomains (location.parent.business.com) Are these fourth-level addresses at risk of being treated differently than the other subdomains? Screaming Frog, for example, doesn't return these fourth-level addresses when doing a crawl for business.com except in the External tab. But maybe I'm just configuring the crawls incorrectly. These addresses rank, but I'm worried that we're losing some link juice along the way. Any thoughts would be appreciated! Technical SEO | | jamesm5i0
- 
		
		
		
		
		
		Questions about the Sandbox and 301 Redirects
 Does the sandbox still exist? What if you have a brand new URL and do a 301 redirect from another website because the name of the service business changed? Thanks for any insight and help. Technical SEO | | SDSLaw0
- 
		
		
		
		
		
		How do I add "noindex" or "nofollow" to a link in Wordpress
 It's been a while since I've SEOed a Wordpress site. How do I add "nofollow" or "noindex" to specific links? I highlight the anchor text in the text editor, I click the "link" button. I could have sworn that there used to be an option in the dialogue box that pops up. Technical SEO | | CsmBill0
- 
		
		
		
		
		
		Can you 301 redirect a page to an already existing/old page ?
 If you delete a page (say a sub department/category page on an ecommerce store) should you 301 redirect its url to the nearest equivalent page still on the site or just delete and forget about it ? Generally should you try and 301 redirect any old pages your deleting if you can find suitable page with similar content to redirect to. Wont G consider it weird if you say a page has moved permenantly to such and such an address if that page/address existed before ? I presume its fine since say in the scenario of consolidating departments on your store you want to redirect the department page your going to delete to the existing pages/department you are consolidating old departments products into ? Technical SEO | | Dan-Lawrence0
- 
		
		
		
		
		
		Why crawl error "title missing or empty" when there is already "title and meta desciption" in place?
 I've been getting 73 "title missing or empty" warnings from SEOMOZ crawl diagnostic. This is weird as I've installed yoast wordpress seo plugin and all posts do have title and meta description. But why the results here.. can anyone explain what's happening? Thanks!! Here are some of the links that are listed with "title missing, empty". Almost all our blog posts were listed there. http://www.gan4hire.com/blog/2011/are-you-here-for-good/ http://www.gan4hire.com/blog/2011/are-you-socially-awkward/ Technical SEO | | JasonDGreat MaeM3.png TLcD8.png
0 MaeM3.png TLcD8.png
0
 
			
		 
			
		 
			
		 
			
		 
			
		 
					
				 
					
				 
					
				 
					
				 
					
				 
					
				