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
-
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 -
Why is Google displaying meta descriptions for pages that are nowhere contained in said page metas?
Certain search keywords are pulling up incorrect page titles and meta descriptions for our site. I've looked through our code, and the text used by Google in the search results is nowhere found inside our site. I've also looked at previous iterations of our site from over a decade ago and still haven't found it. I then searched specifically for the exact phrased incorrect meta descriptions and found a long list of spammy sites linking to our domain with the exact, incorrect meta description. Is this why Google is displaying the incorrect data, and how do I get Google to use the meta descriptions from my actual site?
Web Design | | Closetstogo0 -
How to Redirect Old Domain to a New Domain?
One of my clients has chosen a new domain for her website so we will redirect the old domain to the new. I understand that once redirected, most of the authority built up over the years for the old domain will pass through to the new domain. Is this correct? Can this be done through the Wordpress dashboard, say with a plugin perhaps? I have a plugin called 404 Redirected I was going to try to use for this purpose. Finally, the client has other domains (5 total) she has used for one reason or another. She wants to consolidate all of them and have everything redirected to her new domain. Do you see any downside to this in terms of crawling, Google trust and authority? I know there are some user experience issues to deal with, but we're addressing those. I just don't want to do anything that may cause Google not to trust the new domain. Thanks, Dino
Web Design | | Dino640 -
Homepage Not Displaying Changes
I changed our homepage banner image, and the change shows up if I'm logged into site (it's a WP site). However, when I log out of WP and go to the site, the change doesn't display. I've cleared the cache's, tried different browsers and on different devices, but it only shows the updated version when I'm logged in. Why would that be? And, how can I "force" it to update? Thanks so much! Ruben Site: www.kempruge.com Attached is what it is supposed to display. XxLWPCA.jpg?1
Web Design | | KempRugeLawGroup1 -
Help with redirects
Our travel company used to maintain a set of country destination guides on our site, under the www.oursite.com/destinations/country folder path. Because we offer tours all over the world, we used these pages as high-level guides to each country so a prospect could get a sense of the highlights of those destinations. These pages operated as landing pages too. Unfortunately the pages became stale and unfocused, and we decommissioned them. In order to bring them down, we put a 301 redirect on these URLs, pointing them to a faceted-search page that showed all of our tours to that country, with URLs: www.oursite.com/trips/country. These faceted-search pages were pulling double duty as both search pages and landing pages, which isn't ideal (from a users perspective). We are now in the process of redoing our search function and we'll need to move the search URLs off /trips/ and onto /search/. Within this transition, we are going to re-launch destination guides, and I think the best place for them will be back on the old /destinations/ subfolder. So, a few moving parts here. My question: Do you see problems with reversing the redirect path completely? Ie. where we currently redirect /destinations/country to /trips/country, we are now proposing to redirect /trips/country to /destinations/country. Our concern in this equation is that, over the last few years, we've built up significant link volumes and equity to the /trips/ pages, and we don't want to lose that.
Web Design | | Adventures0 -
What is the code to 301 http to www in htaccess file on unix server
i want to 301 my http home page to www on a linux server and all my other redirects are set up similar to this in my htaccess file: redirect 301 /example-page.html http://www.example-page.html how do I 301 redirect: http://example.com to http://www.example.com I've tried all kinds of code recommended for an htaccess file on a linux server and nothing seems to work. Thanks for the help mozzers! Ron
Web Design | | Ron100 -
301 redirects from old site to new
hey all, we just did a site redesign and have less pages on the new site than the old. is it bad to redirect multiple pages from the old site to the same page on the new? for example redirect ...com/apps ...com/android ...com/mobile and point them all to....com/custom-apps thanks!
Web Design | | jaychow0 -
Will I get penalised for display:none ?
I have initial content that is dislayed for 10secs and then collapsed and replaced by a div that was hidden (display:none). Will the hidden text be used by Google or will they consider it as page stuffing? If so, is there any recommendations on how to handle this. The goal was to maxamize screen real estate for the human visitor without adding clutter.
Web Design | | oznappies0