2017-06-19 63 views
1

我的網站託管在哪裏,我使用的是.htaccess,它有一個條件來刪除www並直接到沒有www的主頁面。www htaccess在網址中與網段重定向

<ifModule mod_rewrite.c> 

Header set X-Frame-Options DENY 

RewriteEngine On 

# Required to allow direct-linking of pages so they can be processed by Angular 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !index 
RewriteRule (.*) index.html [L] 

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www\.(.*) 
RewriteRule (.*) http://meusite.com.br [R=301,L] 

</ifModule> 

問題是這樣的,當有人訪問與WWW內部頁,它愛上了這個檢查,是針對家庭,例如:

如果有人訪問該鏈接:http://www.meusite.com.br/conteudo/94-vai-criar-um-site-to-your-employee-said-you-can-noble

在該條件下它將直接指向http://meusite.com

我需要的是,它是針對以下鏈接:http://meusite.com/content/94-vai-create-a-site-to-your-employee-behavior-which-cannot-can- - 只需從鏈接中刪除www即可。

有誰知道這個檢查是否可以在.htaccess中?

回答

0

Soluction:

RewriteEngine On 
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
1

編輯:

的.htaccess無法您的標題從葡萄牙語翻譯成英文。 您應該使用完全鏈接重定向到普通域,然後使用後端(即php,ruby)進行內部重定向到正確的轉換鏈接。下面您重定向代碼之前,

使用,所以用conteudo鏈接將在這裏獲取,並重定向正確使用反向引用:

RewriteCond %{HTTP_HOST} ^www\..* [NC] 
    RewriteRule ^\/conteudo\/(.*)$ http://menusite.com.br/content/$1 [R=301,L]