使用.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>