htaccess的 - 所有点击量重定向到另一个网站除了请求目录中,也加入WWW [英] .htaccess - Redirect all traffic to another site apart from requests within a directory, also add WWW

查看:136
本文介绍了htaccess的 - 所有点击量重定向到另一个网站除了请求目录中,也加入WWW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想 WWW 添加到URL,然后将所有的流量到另一个域如果请求/秒不是一个目录中。我厌倦了以下code,但它重定向一切,包括 directory1中文件夹名称

  RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ [^。] + \。[^。] + $
(。*)重写规则^ $ HTTP://www.% {HTTP_HOST} / $ 1 [L,R = 301]

重写规则^ directory1中/ $ / directory1中/ [L]

重写规则^(。*)$ http://www.example.com [L]
 

解决方案

请尝试以下规则:

  RewriteEngine叙述上

的RewriteCond%{REQUEST_URI}!^ / directory1中/ [NC]
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^的http://www.newdomain.com% {REQUEST_URI} [L,R = 301]
 

I would like to add www to the url and then direct all traffic to another domain if the request/s are not within a directory. I tired the following code but it redirects everything, including the directory1 folder name

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

RewriteRule ^directory1/$ /directory1/ [L]

RewriteRule ^(.*)$ http://www.example.com [L]  

解决方案

Try these rules:

RewriteEngine on 

RewriteCond %{REQUEST_URI} !^/directory1/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ http://www.newdomain.com%{REQUEST_URI} [L,R=301]

这篇关于htaccess的 - 所有点击量重定向到另一个网站除了请求目录中,也加入WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆