0 votes, average: 0٫00 out of 50 votes, average: 0٫00 out of 50 votes, average: 0٫00 out of 50 votes, average: 0٫00 out of 50 votes, average: 0٫00 out of 5 (0 votes, average: 0٫00 out of 5)
You need to be a registered member to rate this.

کد ریدایرکت htaccess

نمونه کدهای .htaccess برای ریدایرکت کردن صفحات سایت

 

کد ریدایرکت htaccess

کد ریدایرکت htaccess

 

ریدایرکت دائمی

Permanent redirect from example.com to domain.com


  RewriteEngine On
 RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
 RewriteCond %{HTTP_HOST} ^www\.example\.com$
 RewriteRule ^/?$ "http\:\/\/domain\.com\/" [R=301,L]
 

 

ریدایرکت موقتی

Temporary redirect from example.com to domain.com

 

         RewriteEngine On
 RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
 RewriteCond %{HTTP_HOST} ^www\.example\.com$
 RewriteRule ^/?$ "http\:\/\/domain\.com\/" [R=302,L]
 

 

Redirect from example.com/subfolder to domain.com

         RewriteEngine On
 RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
 RewriteCond %{HTTP_HOST} ^www\.example\.com$
 RewriteRule ^subfolder$ "http\:\/\/domain\.com\/" [R=301,L] 
 

 

Redirect from HTTP to HTTPS

          RewriteEngine On
 RewriteCond %{HTTPS} !=on
 RewriteRule .* https://example.com/%{REQUEST_URI} [R,L]یا RewriteCond %{SERVER_PORT} 80
 RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
 RewriteCond %{HTTP_HOST} ^www\.example\.com$
 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] 

 

Redirect from non-WWW to WWW

 

  • for any domain .htaccess takes effect on:
RewriteEngine On
 RewriteCond %{HTTP_HOST} !^www\.
 RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 
  • for a certain domain, example.com:
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
 RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 

 

سایر آموزش ها  آموزش فول بکاپ از تمام اطلاعات سایت در سی پنل

Redirect from WWW to non-WWW

 

  • for any domain .htaccess takes effect on:
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  • for a certain domain, example.com:
RewriteEngine On
 RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
 RewriteRule (.*) http://example.com/$1 [R=301,L]

 

 

Changes the directory root for the main domain to public_html/subfolder


  RewriteEngine on
 RewriteCond %{HTTP_HOST} ^(www.)?example.com$
 RewriteCond %{REQUEST_URI} !^/subfolder/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /subfolder/$1
 RewriteCond %{HTTP_HOST} ^(www.)?example.com$
 RewriteRule ^(/)?$ subfolder/index.php [L] 

کد ریدایرکت htaccess

کد ریدایرکت htaccess

آشنایی با کد های .htaccess