Display a message after 301 redirect.
-
I know this one is a little more technical than pure SEO, but it somewhat ties in.
I'm redirecting 2 sites to one. The companies have combined, and I've imported all their content that has been created, and the url mapping is set up correctly.
So it currently is set up like this:
A.com --> C.com
A.com/blogpost-1 --> C.com/blogpost-1B.com --> C.com B.com/blogpost-20 --> C.com/blogpost-20
What i would like is some method a redirect when landing at C.com or C.com/blogpost-XX.
And in turn display a message in a DIV so I can style it.
And yes, I have nothing better to do on a Friday night
-
Ah sorry about missing the bracket.
Yeah the ? query has to come at the very end, otherwise it interrupts the flow of the URL... So it should be C.com/blogpost-20?redirect=true
There is lots you can do, but I understand that it may be a bit more work than you planned
-
Thanks for this! It wasn't working for me initially, and asked around. looks like you missed a "]" in the first line. So it should be:
if(isset($_GET['redirect'])){
I was able to get it to work at the root domain. A.com --> C.com
After getting this all sorted out though, I realize that I really wanted a pop up screen that could be closed, and that it would require me to spend even more time on it, and trying to add javascript as well. I decided to just scrap the idea.
Another problem I had was that the ?redirect=true at the end of the URL, messed up the direct linking to subpages and posts as well. So instead of :
C.com/blogpost-20 I would get C.com?redirect=true/blogpost-20.
Since there is no such page, it just returned the contents from the home page.
I appreciate your help though. It just seems like more effort that I want to put in, and probably more than the client wants to pay for.
-
P.S. Ensure that you have rel="canonical" on the new URL because otherwise you won't be getting proper SEO for the pages with the ?redirect=true
-
Hi William,
Shouldn't be too hard. In that 301 redirect, add a GET query.
i.e. A question mark after the URL in the redirect that says something like:
http://www.new-url.com?redirect=true
What this will mean is that on your NEW site, you can add a query like (if using PHP):
if(isset($_GET['redirect')){
if($_GET['redirect'] == 'true'){
?>
You were redirected!
}
}
Decoding this, it basically checks for a question mark in the url, and if it finds one, it adds the div with the class "redirected" and says something!
Let me know if that didn't make sense!
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
-
Any risks involved when we have huge list of redirects in our website database?
Hi all, We have changed hundreds and thousands of page and page URLs for last 10 years in our website. So, now we are going to redirect most of the old pages/links to the current related pages. This will increase the number of redirects we set in our website database to thousands. Will this put any extra weight on crawler and any risks involved for employing too many redirects. Thanks
Web Design | | vtmoz0 -
Affects of a Home Link 301 Permanent Redirect in the Main Nav Bar
Hi I created a home page link in the main nav bar using functions.php request, and this leads to the home page, and it works fine. The logo on the site when clicked, resolves the home page domain.com which is fine. Is it ok to have a home page link in my main nav bar, as well as a clickable logo which on-click returns the web user to the home page also? (any seo implications with the permanent 301 redirects?) I like to give web users the choice especially as not all users are aware that they can click back to the home page by clicking on the logo. I considered breadcrumbs already. Thanks.
Web Design | | SEOguy10 -
I want to create a 301 redirect on a WordPress site, nothing's working...
Hello all, I'm hoping someone out there can give me a hand with this. I'm trying to modify my .htaccess file so that the site will go from maxcarnagemusic.com to www.maxcarnagemusic.com and also, so viewers will be redirected to www.maxcarnagemusic.com/home when they try to access the site. I've tried a few different things, including adding the 301 redirect plugin for Wordpress, but nothing seems to work. Can someone out there show/tell me how to create an htaccess file that will execute as much. I apologize in advance, my Apache experience is very, very limited. Thank you all in advance!
Web Design | | maxcarnage0 -
Redirects Not Working / Issue with Duplicate Page Titles
Hi all We are being penalised on Webmaster Tools and Crawl Diagnostics for duplicate page titles and I'm not sure how to fix it.We recently switched from HTTP to HTTPS, but when we first switched over, we accidentally set a permanent redirect from HTTPS to HTTP for a week or so(!).We now have a permanent redirect going the other way, HTTP to HTTPS, and we also have canonical tags in place to redirect to HTTPS.Unfortunately, it seems that because of this short time with the permanent redirect the wrong way round, Google is confused as sees our http and https sites as duplicate content.Is there any way to get Google to recognise this new (correct) permanent redirect and completely forget the old (incorrect) one?Any ideas welcome!
Web Design | | HireSpace0 -
Advanced 301 Redirects
Hi all! I'm moving a blog from a subdomain to a folder on my root domain and want to make sure I am properly implementing 301's. Is there a code or method for making specific pages 301 to the corresponding new URL without having to manually 301 each? For example, a current blog may exist at blog.website.com/3-tips-for-selling-your-home and, since we are moving the blog, will now exist at website.com/3-tips-for-selling-your-home. We obviously want to implement 301's to ensure any link equity carries over to the new url. Anyone know how to implement these in scale to without having to set up each manually? Thanks!
Web Design | | RickyShockley0 -
What happens if I 301 Redirect my homepage to a different page on site
If i were to 301 redirect the index page of my website to a page in a different subdirectory of my site would that adversely affect SEO? Does your home page need to be in the root of your site? I'm asking because a developer has told me that it would be best to do that since he needs to install OpenCart on the root of our domain...
Web Design | | SheffieldMarketing0 -
Do I need to redirect soft 404s that I got from Google Webmaster Tools?
Hi guys, I got almost 1000+ soft 404s from GWT. All of the soft 404s produce 200 HTTP status code but the URLs are something like the following: http://www.example.com/search/house-for-rent (query used: house for rent) http://www.example.com/search/-----------rent (query used:-------rent) There are no listings that match these queries and there is an advanced search that is visible in these pages. Here are my questions: 1. Do I need to redirect each page to its appropriate landing page? 2. Do I need to add user sitemap or a list of URLs where they can search for other properties? Any suggestions would help. 🙂
Web Design | | esiow20130 -
Is it necessary to redirect every Error page (404 or 500) found?
If I have Hundreds of pages with 404 and 500 erros should set up 301 redirects for all of them? Some of the pages have external links, some don't.
Web Design | | jmansd0