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.
-
RewriteCond %{QUERY_STRING} ^p=([0-9_])$
RewriteRule ^(.)$ /p/%1? [R=301,L]the above works on our test area but not on clients so it hosting issue
-
Thanks Chris
Seems there is an issue with the web host.
-
Hi James,
Assuming you want to keep the existing setup but set up friendlier URLs (example, redirect ?p=1_14 to /p/1_14), you could do something like this:
RewriteCond %{REQUEST_URI} ^p=([^&]+) [NC,OR]
RewriteCond %{REQUEST_URI} &p=([^&]+) [NC]
RewriteRule .* /p/%1? [R=301,L,NE]Then you'd want something to handle those new URL requests with something like this:
RewriteRule "^p/(.*)$" "/index.php?p=$1" [L,NE]
Hope this helps!
-
It's from an old website so the pages no longer exist. I will have a look at the link you sent over thank you.
-
Hi,
Something is generating those links, and that is what I would want to fix. It sounds like a module or add-on is incorrectly coded, or installed improperly. As p=1_1 is usually a form of pagination and / or sort order.
You could of course easily fix it by putting a canonical tag on the root page to itself or work out a mod rewrite rule, but that isn't actually fixing the problem. As soon as you add another category you may have to revisit the fix again.
Here is an example of using mod re-write on Stack Overflow: http://stackoverflow.com/questions/14666140/htaccess-rewriting-php-pagination
I hope that helps,
Don
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
-
Proper 301 redirect code for http to https
I see lots of suggestions on the web for forwarding http to https. I've got several existing sites that want to take advantage of the SSL boost for SEO (however slight) and I don't want to lose SEO placements in the process. I can force all pages to be viewed through the SSL - that's no problem. But for SEO reasons, do I need to do a 301 redirect line of code for every page in the site to the new "https" version? Or is there a way to catch all with one line of code that Google, etc. will recognize & honor?
Technical SEO | | wcksmith10 -
Meta descriptions and h1 tags during a 301 redirect
My employer is shifting to a new domain and i am in the midst of doing URL mapping. I realize that many of the meta descriptions and H1 tags are different on the new pages - is this a problem ? Thank you.
Technical SEO | | ptapley0 -
Which way round to 301 redirect?
Hi We have just added a new layered navigation menu to our website. so for example we had Before : www.tidy-books.co.uk/chidlrens-bookcases (this has the seo juice) And Now: http://www.tidy-books.co.uk/childrens-bookcases-book-storage/childrens-bookcases Might be a stupid question but do I redirect the 'now' url to the 'before' url or the the other way round I look forward to hearing your thoughts Thanks
Technical SEO | | tidybooks0 -
Advice on whether we 301 redirect a page or update existing page?
Hi guys, any advice would be really appreciated. We have an existing page that ranks well for 'red widgets'. The page isn't monetised right now, but we're bringing in a new product onto our site that we optimised for 'blue widgets'. Unfortunately, not enough research was done for this page and we've now realised that consumers actually search for 'red widgets' when looking for the product we're creating as 'blue widgets'. The problem with this is that the 'red widgets' page is in a completely different category of our site than what it needs to be (it needs to be with 'blue widgets'). So, my question is; Should we do a 301 redirect from our 'red-widgets' page to our 'blue-widgets' page which we want to update and optimise the content on there for 'red-widgets'. Or, should we update the existing red-widgets page to have the right products and content on there, even thought it is in the wrong place of our site and users could get confused as to why they are there. If we do a 301 redirect to our new page, will we lose our rankings and have to start again, or is there a better way around this? Thanks! Dave
Technical SEO | | davo230 -
Redirect Without Passing Old Page Properties
Is there a way to redirect one page to another, e.g. test.com/ to test.com/home, without passing link juice or any other associated properties of the latter to the former?
Technical SEO | | NTGproducts0 -
301 for a deleted page?
Which is in your opinion the best "301 practice" to notify Google that a web page does not exists anymore? For example: ...
Technical SEO | | YESdesign
---CATEGORY PAGE
-------SUBCATEGORY PAGE
------------ PRODUCT PAGE 1
------------ PRODUCT PAGE 2
------------ PRODUCT PAGE 3
... If you delete “PRODUCT PAGE 2” does it make sense to create in the .htaccess a 301 redirect towards the “SUBCATEGORY”? Do you have others tested methods to deal with this issue? Thank you in advance for sharing your opinions and ideas. YESdesign0 -
Linux Server recognizing ASP Pages (301)
Greeting, I am in the process of 301 a group of pages on our site. We are thinking about switching from ASP to a Linux Server. Question 1. - Would anyone have any information of creating a Sever Spoof so that the Linux Server will recognize asp pages for a 301? Question 2 - How will this style of 301 Effect SEO rankings? Thanks, Tony
Technical SEO | | Tonyd230 -
301 Redirect & re-use
I have an old site which is being moved to a new tld due to re-branding. I understand I would do a series of 301 redirects from the pages of the old site to capture the authority and move to the new site. However, at some point in the future (probably 1-2 years) we may want to re-use the old site again for a different brand (it has a good brand, just not for what we're going after). Question is - can a redirected site be re-used at some point in the future? And if so, which site would new authority (links, etc.) go to?
Technical SEO | | uwaim20120