开发者

mod_rewrite needed

lets says I hav开发者_运维知识库e a domain example.com and I have wildcards dns switched on. on example.com a user can signup with username and password. once registration is done, username.example.com starts redirecting to example.com/script/script.php?user=username. address bar would still show username.example.com

what would be the contents of the .htaccess file to accomplish this?

I have zero expertise with mod_rewrite. please advise. thanks and regards.


You need more than mod_rewrite for this - you also need to read-up on apache virtual hosts.


Assuming your host is configured to serve up all hostnames from the same DocumentRoot, then you'd want something a lot like this:

RewriteEngine On
#If Not Match example.com and Not Match www.example.com
RewriteCond %{HTTP_HOST} !^example\.com
RewriteCond %{HTTP_HOST} !^www\.example\.com
#then rewrite according to this rule
RewriteRule ^(.*)$ script/script.php?user=%{HTTP_HOST}

If you're on shared hosting and can't specify a debug-log file, do your own tests on a test server you have access to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜