2017-06-19 75 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]