0
我想重定向到http://example.com
http://www.example.com
永久重定向:如何管理301重定向域名
我嘗試在我的.htaccess:
RedirectPermanent http://example.com http://www.example.com
它不工作。 我該如何解決這個問題?
我想重定向到http://example.com
http://www.example.com
永久重定向:如何管理301重定向域名
我嘗試在我的.htaccess:
RedirectPermanent http://example.com http://www.example.com
它不工作。 我該如何解決這個問題?
的方法有很多,但我會解釋一下其中的一些:
1.使用重寫規則模塊重定向 - mod_rewrite的:
選項+的FollowSymLinks
RewriteEngine敘述在
RewriteCond%{HTTP_HOST}^domain.com $ [NC]
重寫規則^(。*)$ http://www.domain.com/ $ 1 [R = 301,L]
或
RewriteEngine敘述在
的RewriteCond%{HTTP_HOST} ^!萬維網。(。*) [NC]
重寫規則^(。*)$ http://www.%1/ $ 1 [R = 301,L]
個2.使用重定向腳本:
PHP重定向:
<?php
header(「HTTP/1.1 301 Moved Permanently」);
header(「Location:
http://www.newdomain.ru/newdir/newpage.htm」);
exit();
?>
ASP.NET重定向:
<script runat=「server」>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = 「301 Moved Permanently」;
Response.AddHeader(「Location」,「http://www.new-url.com」);
}
</script>
Ruby on Rails的:
def old_action
headers[「Status」] = 「301 Moved Permanently」
redirect_to 「http://www.new-url.com/」
end
*如果您需要更多信息,請寫下我!
致敬*
RewriteRule很棒!謝謝 ! – Didav