Apache and Nginx Redirect Redirect Guide
In this guide, you will learn how to configure URL redirect operations on Apache and Nginx correctly in terms of SEO.
It is a critical configuration especially for the following scenarios:
- Domain change
- HTTP → HTTPS redirect
- Moving old pages to new URLs
- Site migration without SEO loss
What is Redirect?
Redirect is the process of redirecting a request from one URL to another URL.
Example:
eski-site.com/page
→
yeni-site.com/page
What are 301 and 302 Redirects?
301 Redirect (Permanent Redirect)
- Used when the page is moved permanently
- Transfers SEO value to new URL
- It is the method recommended by Google
Areas of use:
- Domain change
- URL structure change
- HTTPS enforcement
302 Redirect (Temporary Redirect)
- Used for temporary redirects
- SEO value is not transferred to the new URL
- Suitable for maintenance pages
Redirect Configuration on Apache
Redirect operations in Apache:
- Redirect (simple)
- RedirectMatch (regex)
- mod_rewrite (advanced)
Opening the Apache Configuration File
id="p3v8kq"
sudo nano /etc/apache2/sites-available/000-default.conf
1. Simple Redirect (Apache)
<VirtualHost *:80>
ServerName eski-site.com
Redirect 301 / http://yeni-site.com/
</VirtualHost>
2. Specific Page Redirect
Redirect 301 /eski-sayfa http://yeni-site.com/yeni-sayfa
3. RedirectMatch (Regex Based)
RedirectMatch 301 ^/gorseller/(.*)$ http://cdn.site.com/$1
Restarting Apache Service
sudo systemctl restart apache2
Redirect Configuration on Nginx
In Nginx, redirect operations are usually done with return (recommended method).
1. 301 Redirect (Recommended Method)
server {
listen 80;
server_name eski-site.com;
return 301 $scheme://yeni-site.com$request_uri;
2. Regex Rewrite (Advanced)
rewrite ^/eski-dizin/(.*)$ /yeni-dizin/$1 permanent;
Restarting Nginx Service
sudo systemctl restart nginx
Redirect Loop
A redirect loop is a situation where URLs are constantly redirected to each other.
Example:
A → B
B → A
``` id="loop1"
Bu durumda site erişilemez hale gelir.
En Yaygın Hata
- Apache ve Nginx’te aynı domain için çift yönlendirme yapılması
Çözüm
- Yalnızca tek katmanda redirect kullanın (Apache veya Nginx)
SEO Açısından Redirect Kullanımı
301 Redirect
- SEO değerini taşır
- Kalıcı yönlendirmelerde kullanılmalıdır
302 Redirect
- SEO değeri taşımaz
- Geçici durumlar için uygundur
HTTP → HTTPS Yönlendirme (Önerilen)
Apache
```apache id="ssl1"
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Nginx
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
Frequently Asked Questions
What is the SEO difference between 301 and 302?
301 → carries SEO value 302 → temporary redirect, no SEO value
HTTP → Why should HTTPS be 301?
Google considers it as a permanent safe redirect and there is no SEO loss.
What is the difference between RedirectMatch and Rewrite?
- RedirectMatch → simple regex redirect
- mod_rewrite → more complex rules
Why does Nginx redirect faster?
Because it uses the return directive and does not perform any extra processing.
The site does not open after the redirect, why?
The browser cache may not have been cleared. There may be a DNS or SSL redirect conflict.
Result
With this guide:
Redirect management on Apache and Nginx Using 301 / 302 differences correctly SEO compatible URL redirect strategy HTTP → HTTPS forced redirect
You learned the topics.
Proper redirect management is one of the most critical parts of maintaining SEO performance.
You can use GenixNode solutions for more advanced infrastructure management.

