How do I carry out a redirect? Is there a code I need to use?
-
How do I carry out a redirect? Is there a code I need to use? Thank you in advance.
-
@meltingpointgoat maybe I can recommend the following for whats its worth,
I’ve been diving deep into SEO recently and found a bunch of tools that have been super helpful for different aspects of my workflow. Thought I’d share a few in case you find them useful!
https://ralfvanveen.com/en/tools/domain-age-checker/
https://ralfvanveen.com/en/tools/domain-authority-checker/
https://ralfvanveen.com/en/tools/seo-impact-calculator/
https://ralfvanveen.com/en/tools/content-length-vs-ranking-calculator/
https://ralfvanveen.com/en/tools/content-security-policy-csp-checker/
https://ralfvanveen.com/en/tools/backlink-outreach-email-generator/
https://ralfvanveen.com/en/tools/fetch-and-render/
https://ralfvanveen.com/en/tools/bulk-pagespeed-checker/
https://ralfvanveen.com/en/tools/bulk-amp-validator/
https://ralfvanveen.com/en/tools/xml-sitemap-checker/
https://ralfvanveen.com/en/tools/schema-markup-generator/I’ve found these tools over at https://ralfvanveen.com/en/tools/. Thought they were worth sharing!
Are you using similar tools? Would love to know what’s been working for you lately.
Please let me know, I am regularly looking for new ways to optimize my SEO strategies.Regards,
Ulrich
-
Hi!
nice comment -
Redirecting sounds simple, but it can be a lot of work, especially for SEO. You need to carefully map old URLs to new ones, or you risk losing traffic. Big companies often have dedicated teams managing this to ensure everything’s smooth. Implementing strategies like resource smoothing helps here - spreading out tasks over time so no one is overwhelmed and SEO remains on point (see here).
For example, you could have one team member focus on identifying which URLs need redirecting while another handles updating the code over a week, instead of doing everything at once. This way, the workload stays manageable, and there’s less risk of making mistakes.
When implementing redirects, always check for broken links and monitor the changes to ensure traffic isn’t dropping. And remember, a good redirect strategy is essential for maintaining SEO, so take your time and do it right to avoid losing valuable rankings.
-
To carry out a redirect, you can use the following code depending on the language or platform you're working with.
In HTML (meta tag redirect):<meta http-equiv="refresh" content="0; url=https://new-url.com">
In JavaScript:
window.location.href = "https://new-url.com";
In PHP:
header("Location: https://new-url.com"); exit();
Choose the appropriate method based on your environment.
Thanks!
JHK Infotech -
@laurentjb ... Depend on your goals, if you are using cloudflare, you can go to page rules and create 301 / 302 redirect easily
-
Depend on your goals, if you are using cloudflare, you can go to page rules and create 301 / 302 redirect easily
-
@laurentjb said in How do I carry out a redirect? Is there a code I need to use?:
How do I carry out a redirect? Is there a code I need to use? Thank you in advance.
To carry out a redirect, you typically use a piece of code specific to the platform you're working on. For example, in HTML, you can use<meta http-equiv="refresh" content="0;url=http://example.com">
. If you’re using server-side code, such as PHP, you can useheader("Location: http://example.com");
. Just like how you might tweak a Wendy’s Taco Salad recipe to fit your taste, adjusting redirect code ensures your users are sent to the right place. i have wendy's taco salads related site and same done for that website too -
If you are using free CloudFlare DNS and SSL, you can create 301 redirection easily with their tools.
-
Yes, i have done many site like Digitech Journals. To carry out a redirect, you need to use specific code depending on the type of redirect and the server environment you’re working with. The most common types of redirects are 301 (permanent) and 302 (temporary) redirects.
1. Using
.htaccess
(Apache Server)If your website is hosted on an Apache server, you can use the
.htaccess
file to create redirects.a. 301 Permanent Redirect:
Redirect 301 /old-page.html https://www.example.com/new-page.html
- Explanation: This code permanently redirects
old-page.html
tonew-page.html
.
b. 302 Temporary Redirect:
Redirect 302 /old-page.html https://www.example.com/new-page.html
- Explanation: This code temporarily redirects
old-page.html
tonew-page.html
.
c. Redirecting an Entire Domain:
Redirect 301 / https://www.newdomain.com/
- Explanation: This code permanently redirects all pages from the old domain to the new domain.
2. Using PHP for Redirects
If you have access to your website’s PHP code, you can use the following PHP code for redirects.
a. 301 Permanent Redirect:
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: https://www.example.com/new-page.html"); exit(); ?>
- Explanation: This PHP code permanently redirects to
new-page.html
.
b. 302 Temporary Redirect:
<?php header("Location: https://www.example.com/new-page.html"); exit(); ?>
- Explanation: This PHP code temporarily redirects to
new-page.html
.
3. Using JavaScript (Client-Side Redirect)
You can use JavaScript for client-side redirects, though it's generally better to use server-side redirects for SEO purposes.
a. JavaScript Redirect:
<script type="text/javascript"> window.location.href = "https://www.example.com/new-page.html"; </script>
- Explanation: This script redirects the user to
new-page.html
.
4. Using Nginx
If your website is hosted on an Nginx server, you can set up redirects in the Nginx configuration file.
a. 301 Permanent Redirect:
server { listen 80; server_name www.example.com; return 301 https://www.example.com$request_uri; }
- Explanation: This code redirects all HTTP traffic to HTTPS with a permanent redirect.
b. Redirecting a Single Page:
location /old-page.html { return 301 https://www.example.com/new-page.html; }
- Explanation: This code permanently redirects
old-page.html
tonew-page.html
.
5. HTML Meta Refresh (Not Recommended for SEO)
You can use a meta refresh tag in the HTML
<head>
section, but it's not ideal for SEO as it's not a true redirect.<meta http-equiv="refresh" content="0; url=https://www.example.com/new-page.html">
- Explanation: This code redirects after 0 seconds to
new-page.html
.
Choosing the Right Redirect
- 301 Redirect: Use when you want to permanently move a page or domain. This tells search engines to pass the SEO value from the old URL to the new one.
- 302 Redirect: Use when the move is temporary, and you plan to revert to the old URL.
Always test your redirects after implementation to ensure they work correctly and that search engines and users are directed to the intended destination.
- Explanation: This code permanently redirects
-
Complete redirection process requires using 301 redirection
You can redirect your old domain to the new one via Cloudflare or by contacting your hosting manager -
It depends on which type of redirect you mean and what the purpose is. Here are two common scenarios:
For redirecting a single page:
You can use a 301 redirect in your .htaccess file (for Apache servers):Redirect 301 /old-page.html https://www.yoursite.com/new-page.html
For redirecting an entire domain:
To redirect all pages from an old domain to a new one, you can use this code in your .htaccess file:RewriteEngine On RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC] RewriteRule ^(.*)$ https://www.newdomain.com/$1 [L,R=301,NC]
Both methods use 301 (permanent) redirects, which is typically best for SEO. Always test your redirects thoroughly to ensure they work as intended across your site.
-
@laurentjb said in How do I carry out a redirect? Is there a code I need to use?:
How do I carry out a redirect? Is there a code I need to use?
To carry out a redirect, you typically need to use specific code or configurations depending on the type of redirect you want to implement and the server or platform you're working with. The most common types of redirects are 301 (permanent) and 302 (temporary).
But I Recommend you Use Plugins
The Best WP Plugin is ( Redirection )You can use plugins like Redirection or Yoast SEO to manage redirects without needing to write code.
301 Redirect: Use when the original page has permanently moved to a new URL.
302 Redirect: Use when the move is temporary. -
@laurentjb are you talking about domain redirection ?
-
@laurentjb Yes you can redirect 1 page to another using any redirection plugin.
You can either 301(Moved Permanently) or 302(Moved Temporary) the Url 1 to Url 2 -
@laurentjb said in How do I carry out a redirect? Is there a code I need to use?:
How do I carry out a redirect? Is there a code I need to use? Thank you in advance.
To set up a redirect, you typically need to use some code depending on your server environment. For example, if you’re using Apache, you can add a redirect rule to your .htaccess file. Here’s a basic example of a 301 redirect in an .htaccess file:
apache
Redirect 301 /old-page.html http://www.yoursite.com/new-page.html
If you're using Nginx, you would add a redirect rule to your server configuration file like this:
nginx
location /old-page {
return 301 http://www.yoursite.com/new-page;
}For WordPress or other CMSs, there are plugins available that can help you manage redirects without needing to handle code directly.
I hope this helps! Let me know if you have any more questions. because te same issue a=occure with my site then i resolve it by using this method.
Thank you!
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
-
Will URLS With Existing 301 Redirects Be as Powerful As New URLS In Serps?
Most products on our site have redirects to them from years of switching platform and merely trying to get a great and optimised URL for SEO purposes. My question is this: If a product URL has alot of redirects (301's), would it be more beneficial to me to create a duplicated version of the product and start fresh with a new URL? I am not on here trying to gain backlinks but my site is tn nursery dot net (proof:)
Intermediate & Advanced SEO | | tammysons
I need some quality help figuring out what to do.
Tammy0 -
What is the safest way to redirect for best SEO benefits?
What is the safest way to redirect for best SEO benefits? Example: loodgieter-aanhuis.nl -> loodgieters-ambacht.nl Does someone have any technical information on how to (root) redirect for best SEO practices?
On-Page Optimization | | hans-keeren0 -
Redirecting Homepage to Subdomain Bad or Good Idea??
I have a very old forum that still gets a lot of traffic, but when migrating over to another software that is cloud based we cannot redirect using same domain, SO the only option would to be to change the cname on a subdomain and then REDIRECT all the traffic from the ROOT domain permanently - would this be a bad move as the root domain wouldnt be used anymore as now its just setup to be redirected in order to use the software we need to use? Domain is 17 years old.
Technical SEO | | vbsk0 -
What is the difference between "document" and "object" moved redirect errors?
What is the difference between "document" and "object" moved redirect errors? I'm used to see "object moved" as a redirect chain issue that needs to be fixed, but this week my report contained a "document moved" redirect chain issue. And it's on our homepage. Looks like it might be a HTTP versus an HTTPS issue.
Reporting & Analytics | | Kate_Nadeau0 -
How can I redirect anything after the article url to main article?
Hello everyone, When someone visits my websites article like http://www.website.com/article-title/lol , it give to 404 page error. But when someone http://www.website.com/article-title/ , it shows the article. The word "lol" can be changed to anything. I would like that to be redirected to the main article. Example: Someone visits website.com/article-title/lol, they should be redirected to website.com/article-title/ Is it possible to do so? If yes, please tell me how. Note: I'm using WordPress Thank you
On-Page Optimization | | hakhan2011 -
Redoing a site - 404 redirect or 301 redirect
I'm redoing a website, should i 404 the old pages, or 301 redirect to the main page? what is better? (around 100 pages)
On-Page Optimization | | mkmedia0 -
Using rel="author" on product descriptions
Unique and effective product descriptions can be one of the most expensive investments that go into building a retail website. I would consider them part of the "intellectual property" of a company. These descriptions are also one of the most often pirated types of content. Some product descriptions have been grabbed and used by hundreds of pirates. When people grab your product descriptions it creates a duplicate content problem, it also starts cutting off your long-tail traffic. The discussion topic here is.... Have you heard of anyone using rel="author" on product pages with substantive content? Do you think there is any value in doing that? Is this an abuse of rel="author" Thank you!
On-Page Optimization | | EGOL1 -
Building content pages, redirecting and linking
Previously the company had created some .HTML content pages around top shoe styles and top manufactures. One or two of these pages used to rank but have been neglected over the page 18 months. I want to build out new content round our top styles / top manufactures and I am wondering if I should use the existing HTML pages or create new pages that use our content management system. The .HTML pages can contain keywords in the URL, using our content management system, all URL’s are www.site.com/content/home/contentid=1234abcd. If we use the .HTML pages all content is managed manually. If we build out 6 to 10 pages, this can become a resource issue and may result in a bad experience for the website visitor. From an SEO perspective, does the benefit of having the keywords in the URL outweigh the manual management hassles? And if not, should we 301 all the HTML pages to the new content pages? And from a linking standpoint, I want these content pages to point to the new version of the top style. From a navigation standpoint, we also want to provide access to all styles from the manufacture. Should we nofollow the links to all styles?
On-Page Optimization | | seorunner0