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
-
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 -
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 -
Https Implementation - Weird Redirection After Putting 's' in http://
Hi Mozers, I have come across some websites with their https version going to a totally different website. For example, http://www.samplesite1.com will load fine but when the protocol is changed to https (https://www.samplesite1.com) it will go to a total different domain say, https://www.samplesite2.com How does this happen, in technical sense? In the warning from browser, it says the the security certificate is from the other website but I would like to understand how this happens and how it impacts SEO. I seem to be not able to understand the relationship of this error and SEO impact. Thanks in advance for your response. Malika
Web Design | | Malika10 -
Home page redirect - will this cause an SEO problem
Hello, We are using Wordpress to build a wiki site. The wiki plugin we're using (Wordpress Wiki lite) can only be set up on an internal page like nlpwiki(dot)org/wiki Can we redirect the home page to the /wiki subdirectory and use nlpwiki(dot)org/wiki as our home page? I've never done that, just wondering if it will be indexed as the home page or if there are any connonical issues. Thanks!
Web Design | | BobGW0 -
301 Redirect ! Joomla Pages, Already ranking. ( just wanted to change the url
hey guys hope everyone had a new year. I am ranking for a page on my site that i want to ( not specifically move ), but just change the url name: It is too long i think and i want to move it from one portion of my architecture to another menu. I have never physically done a 301 redirect myself, always had someone do it for me. I wanted some pointers. Since it is a fairly new site 4 months old! What are my options. Do i need to 301 redirect the page, if i am changing the Structure and AI of my site, or can i just change the url as is and it will still get ranked? How do i keep that url put delete the page and redirect it ? Sorry its very simple but i wanted to get the communities help to continue on ! Best Wishes HAmpig
Web Design | | BizDetox0 -
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 -
Website Redesign 301 Question
Hey Moz gang, I have a question that I believe I know how I'm going to handle, but just wanted some feedback from the Moz community on best practices. At my company, we're going through a site redesign. At the moment, our site is deeper than it should be with many one-off feature pages. For example, we have a Features page that then links to individual pages for each specific feature. One goal we have set for the redesign is a condensing of the pages in order to make the site more user-friendly, easy to manage and content rich. My question is this. We have a lot of these individual pages that I want to essentially kill and merge into one page. It is okay (best practice) to 301 all of those individual feature specific pages to the single Features page since that is now where all of that content lives?? I want to retain the link juice that those pages have gained over time, but I don't want to get penalized for too many 301's to a single page. Any advice or previous experience would be awesome 🙂 Thanks, Lance
Web Design | | RobinBryant10 -
Is it common to have some of error/warning(currency duplicate,redirect, etc...) in most website that rank well?
Hi could any body could give me some idea on 'on page optimisation' Currently in my campaign I have around 3000+ errors, 14,000+ warning, 7000+ notices for the following reasons: Overly-Dynamic URL
Web Design | | LauraHT
Temporary Redirect
Title Element Too Long (> 70 Characters)
Duplicate Page Title
etc... First of all I know these have negative effect on SEO. Now to fix towards those issues it involve lots of works and times. At the same time most of our important keywords/url rank position have not changed over the last 12 months. Does that mean the above has only limited negative effect? I just want to know is it worthy to invest the man/hour/money to clean those issues. As it involves decent development time. Is it common to have some of error/warning in most website that rank well? (e.g. I 've seem may big website have duplicate title/meta-desc on their currency variant page)0