Website Redirection¶
Redirect visitors from one address to another using HTML.
-
Domain Change
Redirect from old domain to new one.
-
Content Move
Page moved to new URL.
-
Maintenance
Temporary redirect during maintenance.
-
Simple
No server configuration required.
When to use redirection?¶
- Domain Change
-
old-domain.sk→new-domain.sk - Content Move
-
/article.html→/new/article-2025.html - Site Maintenance
-
Temporary redirect during deployment of new version.
Redirection types¶
| Method | Use Case | SEO Impact |
|---|---|---|
| HTML meta refresh | Simple, quick | Weaker |
| .htaccess 301 | Permanent redirect | Best |
| PHP header | Dynamic redirect | Good |
Recommendation
For permanent redirects, use .htaccess 301. HTML redirection is suitable for quick and temporary solutions.
HTML redirection¶
Immediate redirect¶
Create or edit index.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=https://www.new-site.sk">
<title>Redirect</title>
</head>
<body>
<p>If you are not automatically redirected,
<a href="https://www.new-site.sk">click here</a>.</p>
</body>
</html>
Explanation
content="0; url=..." redirects immediately (0 seconds).
Delayed redirect¶
Show message before redirecting:
This redirects after 5 seconds. This is suitable for:
- Maintenance notice
- Information about page relocation
- New version notification
.htaccess redirection (301)¶
For permanent redirects, create .htaccess file:
# Redirect entire domain
Redirect 301 / https://www.new-domain.sk/
# Redirect specific page
Redirect 301 /old-page.html https://www.new-domain.sk/new-page.html
SEO
301 redirect is best for SEO, because it preserves page ranking.
Method comparison¶
| HTML refresh | .htaccess 301 | |
|---|---|---|
| Implementation | Very simple | Requires .htaccess access |
| SEO | Weaker | Best |
| Server settings | Not needed | Required |
| Type | Temporary | Permanent |
Common mistakes¶
Infinite loop
Page redirects to itself.
Solution: Check the URL in the redirect, it must be different from the current one.
Redirect does not work
Browser caches old version of page.
Solution: Clear browser cache or use Ctrl+F5.
SEO issues
HTML redirection is not ideal for search engines.
Solution: For permanent redirects, use .htaccess 301.