用.htaccess伪静态将域名绑定子目录

来源:互联网 发布:戚薇淘宝店怎么没了 编辑:程序博客网 时间:2024/05/18 01:30
首先把域名做好解析,比如把www.aoyou0898.com和demo.aoyou0898.com解析到127.1.0.1这个IP,然后是在网站管理面板里,为网站绑定www.aoyou0898.com和demo.aoyou0898.com。最后编辑配置.htaccess文件,就可以了

在网站的跟目录创建.htaccess,代码如下:

<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{HTTP_HOST} ^((www|wap)\.)?wap\.aoyou0898\.com$RewriteCond %{REQUEST_URI} !^/wap/RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /wap/$1RewriteCond %{HTTP_HOST} ^((www|wap)\.)?wap\.aoyou0898\.com$RewriteRule ^(/)?$ wap/index.php [L]RewriteCond %{HTTP_HOST} ^(www\.)?aoyou0898\.com$RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php [QSA,L]</IfModule>

要绑定的是把demo.aoyou0898.com绑定到demo目录中,所以不仅要在根目录放置.htaccess文件,还要在demo目录中放置.htaccess文件,demo目录中的.htaccess写法如下:

<IfModule mod_rewrite.c>RewriteEngine On RewriteBase /demoRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /wap/index.php [L]</IfModule>


0 0
原创粉丝点击