使用.htaccess伪静态将域名解析到目录,具体方法如下:
1.首先,在网站根目录中创建一个.htaccess文件;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^((www|wap)\.)?wap\.aoyou0898\.com$
RewriteCond %{REQUEST_URI} !^/wap/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wap/$1
RewriteCond %{HTTP_HOST} ^((www|wap)\.)?wap\.aoyou0898\.com$
RewriteRule ^(/)?$ wap/index.php [L]
RewriteCond %{HTTP_HOST} ^(www\.)?aoyou0898\.com$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
2..htaccess文创建好后,执行以下命令将伪静态域名解析到指定的目录即可;
例:将伪静态域名解析demo目录中
<IfModule mod_rewrite.c>
RewriteEngine On RewriteBase /demo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wap/index.php [L]
</IfModule>