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
-
We use bigcommerce platform and want to access the bigcommerce server to change the way our product images display
Hi We use bigcommerce and want to chage the way we display multiple images for our products. At the moment in bigcommerce you switch between images by clicking the next image, we want the images to change when we hover the curser over the image. Does anyone know how to do this ? Regards Adrienne
Web Design | | CostumeD0 -
Do I need to 301 redirect www.domain.com/index.html to www.domain.com/ ?
So, interestingly enough, the Moz crawler picked up my index.html file (homepage) and reported duplicate content, of course. But, Google hasn't seemed to index the www.domain.com/index.html version of my homepage, just the www.domain.com version. However, it looks like I do have links going specifically to www.domain.com/index.html and I want to make sure those are getting counted towards my overall domain strength. Is it necessary to 301 redirect in the scenario described above?
Web Design | | Small_Business_SEO0 -
What should I know about redirecting users based on cookies?
Hi Moz! My client wants to redirect users to a basic or professional version of their site based on cookies. What do we need to do/know to make sure implementation is SEO-friendly? What if a user has cookies turned off? Are there any other obstacles? Thanks for reading!
Web Design | | DA20130 -
HELP! IE secure page display issue on new live site
For some reason IE 7, 8, & 9 do not display the following page: https://www.jwsuretybonds.com/protools.htm All they show is the Norton seal. It shows properly in all other browsers without issue (including IE 10+), but the earlier versions flash the page for a split second, then hides everything. Can someone shed some light on this? This is a new live site we just launched minutes ago and these browsers account for 12% of our overall traffic. UGH I hate you microsoft!!! Thanks all 🙂
Web Design | | TheDude0 -
HTTPS redirecting to subdomain; do I need to 301 to HTTP first?
Hello there, quick question on HTTPS downgrade to HTTP. Originally, full site was HTTPS. Redesign eliminated need for secure layer. Site currently has https 301'd to sub.domain.com. Ideally, site would live at domain.com, but with the old site having been indexed https, the security warning triggers when you visit, hence the 301 to a subdomain. Thinking possible solutions here are to a) add back in secure layer or b) 301 all old https pages to new http pages. Have I overlooked something? With (a), I will see no SEO impact, correct? With (b), can I expect impact similar to a relaunch? Have seen a lot of chatter that there is some impact in switching http to https, but not much the other way. Any help much appreciated!
Web Design | | alimo0 -
Redirection Of Mobile Traffic
Hi, I hope someone can help me with this, we have been working on creating a mobile version of our website, but does anyone know of a way of ensuring that mobile traffic is redirect to our mobile version, ie m.mydomain.com Thanks Rich
Web Design | | mos_rich0 -
Redirecting duplicate pages
For whatever reason, X-cart creates duplicates of our categories and articles so that we have URLs like this www.k9electronics.com/dog-training-collars
Web Design | | k9byron
www.k9electronics.com/dog-training-collars/ or http://www.k9electronics.com/articles/anti-bark-collar
http://www.k9electronics.com/articles/anti-bark-collar/ now our SEO guy says that we dont have to redirect these because google is "smart enough" to know they are the same, and that we should "leave it as-is". However, everything I have read online says that google sees this as dupe content and that we should redirect to one or the other / or no /, depending on which most of our internal links already point to, which is with a slash. What should we do? Redirect or leave it as is? Thanks!0 -
Page Redirection solution
Page Redirection solution needs, there are 2 sites in the same folder and one page of old site is bxxxxxseo.com/products.php new site bxxxxxseo.com/product_list.php .there are many old page indexed i wanna redirect all old pages to relevant pages of new site using SEO friendly way .Any help really appropriate. Thank you
Web Design | | innofidelity0