PHP Apache URL 重写
1、LoadModule rewrite_module modules/mod_rewrite.so 启动(将前面的#去了)
2、修改:
1 2 3 4 5 6
| <Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory>
|
AllowOverride none 改为 All
PHP Apache泛域名应用
以Windows开发环境
1、windows 下的 hosts文件
1 2 3 4
| 127.0.0.1 asia.t 127.0.0.1 *.asia.t 127.0.0.1 www.asia.t 127.0.0.1 coca.asia.t
|
2、apache 下的 httpd-vhosts.conf文件
1 2 3 4 5
| <VirtualHost *:80> DocumentRoot E:\www\asia\www ServerName *.asia.t ServerAlias *.asia.t </VirtualHost>
|
3、php处理
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
|
$site_url = $_SERVER['HTTP_HOST']; $site_url = explode('.',$site_url); if(count($site_url)<3) { define('DOMAIN','www'); define('SITEDOMAIN',$_SERVER['HTTP_HOST']); define('BASEDOMAIN',SITEDOMAIN); } else { define('DOMAIN',$site_url[0]); if(DOMAIN == 'www') { define('SITEDOMAIN',$_SERVER['HTTP_HOST']); define('BASEDOMAIN',str_replace('www.','',SITEDOMAIN)); } else { define('BASEDOMAIN',str_replace(array(DOMAIN.'.',DOMAIN),array('',''),$_SERVER['HTTP_HOST'])); define('SITEDOMAIN',DOMAIN.'.'.BASEDOMAIN); } }
|