-2
我堅持一個問題,它不能夠解決這個問題。 Plz幫助我擺脫這一點。
我的要求是: 我希望每個城市的名稱都是我網站中的子域名。說www.mysite.com,可以有www.delhi.mysite.com,www.bangalore.mysite.com。名單可能會無窮無盡。我的問題是我不想爲每個子域創建文件夾。我想在URL中以查詢字符串的形式處理它,比如www.mysite.com?city=bangalore。這樣我可以將請求重定向到單個文件。
我已經建立了LAMP架構。
在虛擬主機文件,它是
<VirtualHost 127.0.0.1:80>
ServerAdmin [email protected]
ServerName www.mysite.com
DocumentRoot /var/www
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerAdmin [email protected]
ServerName *.mysite.com
DocumentRoot /var/www
</VirtualHost>
而且更新的.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/index.html [R,L]
不過還是我得到404錯誤。
我的方法是否正確?它可以實現嗎?
請幫我做這件事。
可能重複的:http://stackoverflow.com/questions/49500/apache-rewrite-based-on-subdomain http://stackoverflow.com/questions/4193651/simple-htaccess-subdomain-rewrite http ://serverfault.com/questions/203780/troubleshooting-a-htaccess-wildcard-subdomain-rewrite/203804#203804 –