在 httpd 中将一个域名转发到另一个域名
在< virtualhost> 中添加下面的重定向规则:
RewriteEngine On # Redirect webhosting-world.com/forums to bbs.wbhw.com RewriteCond %{REQUEST_URI} ^/forums/ RewriteRule /forums/(.*) http://bbs.wbhw.com/$1 [R=permanent,L] # Redirect webhosting-world.com to wbhw.com RewriteCond %{REQUEST_URI} !^/forums/ RewriteRule /(.*) http://www.wbhw.com/$1 [R=permanent,L]
添加了上面的规则以后, 里的全部内容如下:
< virtualhost *:80> ServerAlias webhosting-world.com ServerAdmin admin@webhosting-world.com DocumentRoot /path/to/webhosting-world/root ServerName www.webhosting-world.com RewriteEngine On # Redirect webhosting-world.com/forums to bbs.wbhw.com RewriteCond %{REQUEST_URI} ^/forums/ RewriteRule /forums/(.*) http://bbs.wbhw.com/$1 [R=permanent,L] # Redirect webhosting-world.com to wbhw.com RewriteCond %{REQUEST_URI} !^/forums/ RewriteRule /(.*) http://www.wbhw.com/$1 [R=permanent,L] < /virtualhost>
1.http://www.zzz.com/xxx.php-> http://www.zzz.com/xxx/ 2.http://yyy.zzz.com-> http://www.zzz.com/user.php?username=yyy 的功能 RewriteEngine On RewriteCond %{HTTP_HOST} ^www.zzz.com RewriteCond %{REQUEST_URI} !^user\.php$ RewriteCond %{REQUEST_URI} \.php$ RewriteRule (.*)\.php$ http://www.zzz.com/$1/ [R] RewriteCond %{HTTP_HOST} !^www.zzz.com RewriteRule ^(.+) %{HTTP_HOST} [C] RewriteRule ^([^\.]+)\.zzz\.com http://www.zzz.com/user.php?username=$1
/type.php?typeid=* --> /type*.html /type.php?typeid=*&page=* --> /type*page*.html RewriteRule ^/type([0-9]+).html$ /type.php?typeid=$1 [PT] RewriteRule ^/type([0-9]+)page([0-9]+).html$ /type.php?typeid=$1&page=$2 [PT]
按字母顺序浏览:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
→我们致力于为广大网民解决所遇到的各种电脑技术问题 如果您认为本词条还有待完善,请 编辑词条
上一篇Linux常用命令大全
下一篇Linux查看端口使用状态及启动