AliMD / 1Tuts

:+1: Web Design Technology Tutorials
http://ali.md/tuts
62 stars 41 forks source link

how to create 301 redirect on my cpanel? #586

Closed omidgharib closed 11 years ago

omidgharib commented 11 years ago

salam dustan kasi midune chejori mishe ke 301 redirect besazam vase sitam roye cpanel?

AliMD commented 11 years ago

az panel redirect kheyli sade mishe sakht !

omidgharib commented 11 years ago

mer30 @AliMD nigah konid mikham www.omidgharib.ir ba omidgharib.ir yeki bashe to siti ke vase seo sitam estefade kardam error dade va mig ke in ghaziyaro ba 301 redirect dorost konam?

AliMD commented 11 years ago

jan !!! aha ye .htaccess besaz ino baras benevis

# ----------------------------------------------------------------------
# Suppress or force the "www." at the beginning of URLs
# ----------------------------------------------------------------------

# The same content should never be available under two different URLs -
# especially not with and without "www." at the beginning, since this can cause
# SEO problems (duplicate content). That's why you should choose one of the
# alternatives and redirect the other one.

# By default option 1 (no "www.") is activated.
# no-www.org/faq.php?q=class_b

# If you'd prefer to use option 2, just comment out all option 1 lines
# and uncomment option 2.

# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!

# ----------------------------------------------------------------------

# Option 1:
# Rewrite "www.example.com -> example.com".

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

# ----------------------------------------------------------------------

# Option 2:
# Rewrite "example.com -> www.example.com".
# Be aware that the following rule might not be a good idea if you use "real"
# subdomains for certain parts of your website.

#<IfModule mod_rewrite.c>
#  RewriteCond %{HTTPS} !=on
#  RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#  RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#</IfModule>

More: https://github.com/AliMD/1Net/blob/master/.htaccess

omidgharib commented 11 years ago

@AliMD tashakore faravan ostad :+1: