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
-
WordPress redirects are taking too long to navigate: Anyone ever faced this?
Hi community, We are using wordpress website. We have redirected hundreds of URLs from wordpress redirect manager for last 10 years around. Suddenly from last one week, the redirects are taking too long to navigate to the pages; like around 1 minute. Could you anybody face the same issue? Please help me on this. Thanks
Web Design | | vtmoz0 -
Should I do multiple 301 redirects?
We launched our website less than a year ago. We had another domain name and business name. I created 301s from the old domain to the new domain, that are still in place now. We are in the process of restructuring our current site which would result in pages getting a new title and URL to match. Essentially it would look something like this:
Web Design | | MAVENTRI
-- olddomain.com/page1 --> newdomain.com/page1 --> newdomain.com/newpage I recently checked the analytics and it looks like we are still getting traffic redirected from the old domain. What is the best way to handle these redirects? Should I redirect a redirect?0 -
New ecommerce site: Close old site and full domain redirect or keep it linking to new site?
We have rebranded and are working on our new site (B). Our old site (A) has a much higher domain/page authority than our new site. Currently we have the original Site A still there, with all links/pages pointing to the new Site B when people click. I am unsure whether we'd be best to close down the Site A completely and do a full domain redirect to Site B. Site A: 10 years age and has a moderate amount of links to it.
Web Design | | ModowestNZ
Homepage - PA: 24 DA:11 Site B: 6 months age, few links
Homepage - PA: 1 DA:2 My concern with the full domain redirect is that the indexed/ranking pages would dissapear. The benefit is less brand confusion for our niche range of party accessories.0 -
Looking to remove SSL because it is causing very slow website download speeds. Does WP have a plugin that redirects SSL urls to non SSL urls?
After some extended debate with our web development team we are considering dropping the SSL from our website because it is adding almost 2 additional seconds to our download speeds. We know there is a SEO boost from having a SSL but we believe the extended download speeds maybe outweighing the benefit. However we are concerned about the SEO implications of having no method possible of redirect SSL to non SSL webpages. Does anybody know of a Wordpress Plugin that can force redirect SSL urls to non SSL urls?
Web Design | | RosemaryB0 -
Is there a way to redirect URLs with a hash-bang (#!) format?
Hi Moz, I'm trying to redirect www.site.com/locations/#!city to www.site.com/locations/city. This seems difficult because anything after the hash character in the URL does not make it to the server thus cannot be parsed for rewriting. Is there an SEO friendly way to implement these redirects? Thanks for reading!
Web Design | | DA20130 -
Google Malware Message
*Update 9/19/2013 So I finally have more details the site is a joomla site and is hosted on godaddy. The weird thing is the malware message only appears when browsing the site in chrome it comes up fine in internet explorer any specific reason why that would be? Also we noticed that on the joomla template there were about 6 scripts after the tag that were adult site related and have nothing to do with our site, any ideas? I appreciate all/any suggestions and or advice. Thank You. I had a client recently pay about $300 for a site design that she hosted on go daddy. This is the site www.shirianfabric.com can anyone tell me why this would happen its only been live for about three months and out of no where we get this message? My client is thinking maybe the designer inserted some kind of malicious code?as he is now charging a couple hundred to fix the issue. Is there any way to look further into this? Im not sure a webmasters account was ever set up for this site so any advice would be greatly appreciated. Thanks.
Web Design | | aaseo1230 -
Site Re-Design - Running old XML site map for 301's
Hi all, We are going to launch a new site design for our current e-commerce site. I have taken this opportunity to change some categories due to keyword research and all old categories will be 301ed to best fitting new category. So I have 2 questions about moving stuff over; 1. I read that leaving the old xml site map running for the first week, would help, because this would give crawlers the chance to run through the site and follow the 301s, which would help pass the juice. How true does this sound? 2. I was thinking of re-writing all category and sub category titles, meta descriptions and on page content. The positive of this is loads of fresh content - but doing this all at the same time with the new site launch might see some major dropping in search ranking. I've identified our top traffic keyword terms/pages, would it be more wise to leave these pages, and change the others, or would the total new fresh burst have a better impact? Cheers
Web Design | | ToxicFox0