Introduction
Redirects serve as essential tools for company websites, offering numerous benefits for effective management:
- Adapting to Changes: As companies frequently update, reorganize, or remove web pages, redirects play a vital role in ensuring a smooth transition. By automatically steering visitors toward new or relevant pages, redirects prevent the frustration of encountering broken links or error messages.
- Safeguarding SEO Standing: Search engines like Google consider factors such as link quality and quantity when determining a page's search result ranking. Without proper redirects during website structural changes or URL modifications, a company risks losing valuable SEO rankings. Redirects are the solution, preserving search engine visibility by indicating page movements.
- Elevating User Experience: Delivering a positive user journey is paramount to retaining and engaging website visitors. Redirects shine in this area by seamlessly guiding users to the appropriate content. This eliminates confusion and irritation that may arise when users click links or enter URLs.
- Optimizing Marketing Endeavors: Marketing campaigns often feature specific landing pages, which might become obsolete once campaigns conclude. Redirects prove their utility by channeling traffic from these promotional URLs to other relevant destinations, ensuring a continuous flow of user engagement.
In a nutshell, redirects are indispensable for maintaining seamless user experiences, upholding SEO rankings, and deftly managing shifts in a company's website structure, content, and URLs. They serve as custodians of brand credibility, website user—friendliness, and overall digital prosperity.
Requirements
- Root rights;
- Several knowledge about work OS ;
- Internet connection.
Installation
First of all we need to update all packages in the system and install them:
If you already have web—server with html or php—page then skip that stage, for other case we setup web—server step—by—step. We need to download web—server in our example that woudl be Apache. Type the command below:
Let's configure environment for settings web—server, open the main configuration file:
And changes all parameters AllowOverride to value All, that needed for properly work .htaccess files, which we will create in worker directory of site. Then press combination of Ctrl+O and Ctrl+X for save and exit. Create worker directory for site and two html pages for redirecting:
By the command below make a html page for start redirect:
Enter that HTML—code below or use your own page:
<html>
<head>
<title>FIRST PAGE</title>
</head>
<body>
<h1>That starting page!</h1>
</body>
</html>
By the command below make a html page for target site:
Enter that HTML—code below or use your own page:
<html>
<head>
<title>SECOND PAGE</title>
</head>
<body>
<h1>Congratulations, you are in target site!</h1>
</body>
</html>
After we create page for our manipulation, we can go to the settings of the site by the command below:
And edit accordance parameters for properly work, indicate DocumentRoot as folder we created before, ServerName in that field enter domain name and in the last for your directory changes AllowOverride to All! Ctr+O and Ctrl+X for saving and exit of file:
Redirect
Now we can create .htaccess file for redirecting our page by various HTTP code, let's create a file by the command below:
For make permament redirect we need to indicate HTML—page by the command and syntax below:
RewriteRule ^start$ /target [R=301, L]
RewriteRule ^start$ index.html
RewriteRule ^target$ index2.html
In the first line we indicate enabled status of module override, at the second we can see redirect rule with code 301 , at the third we assign index.html with start label and target accordance to index2.html.
Restart our web—server and enable override module:
Let's check implementation of our redirecting, go to the web—site:
The second page looks like this:
We have redirected, make sure by the tools in the browser, press F12 and monitor HTTP/S query from client and server:
Alright we see in the status column 301 HTTP redirect code therefore all system and web server configuration work properly! Next, if we want to change redirecting code, then we need just a little modified previous configuration:
Enter that code instead of previous configuration:
RewriteRule ^start$ index.html
RewriteRule ^target$ index2.html
In that case we straight indicate for redirecting by the syntax above Redirect, then choose HTTP code for this and save file! Let's check the result:
Conclusion
The redirects serve as indispensable tools for maintaining a seamless user experience, preserving SEO rankings, and skillfully managing shifts in a company's website structure, content, and URLs. By strategically implementing various types of redirects, businesses can foster brand credibility, enhance website user—friendliness, and achieve digital prosperity. The process of implementing redirects in Apache2 involves configuring the web server and creating .htaccess files to control redirection behavior effectively. Properly setting up redirects ensures that users are directed to the right content, contributing to a successful online presence.