其实重定向的方法设置说了几次了,以前的文章《通过Rewrite实现特定IP访问网站》以及昨天发布的给《老域名进行重定向设置的原因》,都是和重定向相关的。今天主要是说下如何实现顶级域名到二级域名的重定向设置方法:
1:apache环境[需要mod_rewrite支持].htaccess
0 1 |
RewriteEngine on RewriteRule ^(.*)$ http://www.selmy.org/$1 [R=301,L] |
2:win2003环境httpd.ini
0 1 2 3 4 5 |
[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 RewriteCond Host: ^selmy\.org$ RewriteRule (.*) http\://www\.selmy\.org$1 [R,I] |
3:win2008环境web.congif
0 1 2 3 4 5 6 7 8 9 |
web.config文件代码如下 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules><rule name="CanonicalHostNameRule1" enabled="true"><match url="(.*)" /><conditions><add input="{HTTP_HOST}" pattern="^www\.t4x\.org$" negate="true" /></conditions><action type="Redirect" url="http://oldblog.t4x.org/{R:1}" /></rule> </rewrite> </system.webServer> </configuration> |
4:lighttpd
1:使用putty登陆linux服务器。
2:/etc/lighttpd/conf/kloxo/lighttpd.yourdomain.com [注解:yourdomain.com为你的域名,我的也就是lighttpd.selmy.org]
3:使用vi编辑lighttpd.selmy.org。[默认中有很多的配置文件]
4:第一次配置如下:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
$HTTP["host"] = “selmy.org” { url.redirect = (“^/(.*)” => “http://www.selmy.org/$1″) } $HTTP["host"] =~ “^(www.selmy.org)”{ alias.url = (“/__kloxo” => “/home/admin/kloxoscript”) url.redirect = (“/webmail” => “http://webmail.selmy.org”) url.redirect += (“^kloxo$” => “https://cp.selmy.org:7777″) url.redirect += (“/kloxononssl” => “http://cp.selmy.org:7778″) url.redirect += (“/stats/” => “http://selmy.org/awstats/awstats.pl”) url.redirect += (“/stats” => “http://selmy.org/awstats/awstats.pl”) server.document-root = “/home/admin/xlblp/” index-file.names = (“index.php”, “index.html”, “index.shtml”, “index.htm”, “default.htm”, “Default.aspx”, “Default.asp”, “index.pl”) alias.url += ( “/awstatsicons” => “/home/kloxo/httpd/awstats/wwwroot/icon/” ) alias.url += ( “/awstatscss” => “/home/kloxo/httpd/awstats/wwwroot/css/” ) alias.url += (“/awstats/” => “/home/kloxo/httpd/awstats/wwwroot/cgi-bin/”) $HTTP["url"] =~ “^/awstats” { cgi.assign = ( “.pl” => “//home/httpd/selmy.org/perlsuexec.sh” ) } alias.url += ( “/cgi-bin” => “/home/admin/xlblp/cgi-bin/”) $HTTP["url"] =~ “^/cgi-bin” { cgi.assign = ( “” => “//home/httpd/selmy.org/shsuexec.sh” ) } accesslog.filename = “/home/httpd/selmy.org/stats/selmy.org-custom_log” server.errorlog = “/home/httpd/selmy.org/stats/selmy.org-error_log” cgi.assign = ( “.php” => “/home/httpd/selmy.org/phpsuexec.sh”, “.pl” => “/home/httpd/selmy.org/perlsuexec.sh” ) $HTTP["url"] =~ “^/stats” { dir-listing.activate = “enable” } } |
申请:本文为Byrd原创,转载于之前个人博客!SourceByrd's Weblog-https://note.t4x.org/basic/rewriterule-htaccess/ SourceByrd's Weblog-https://note.t4x.org/basic/rewriterule-htaccess/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!