Пожалуйста, предложите мне, как я могу это сделать.
Спасибо
Я могу ошибаться, но я не знаю, возможно ли переписать URL так же, как вы используете поддомены. Если это то, что вам нужно сделать через IIS, я уверен. The real napster 21.08.2009
Вам нужно решить, к чему вы не обращались, - это как вы собираетесь получить имя пользователя и как вы собираетесь обрабатывать их внутри.
Но на самом деле вам не нужен URL Rewriter. Вы просто перенаправляете весь DNS-трафик на один и тот же IP-адрес, а затем обрабатываете домен в своем приложении вместо того, чтобы контролировать его через DNS.
Ответ 2 · The real napster
Это возможно при установленном на сервере ISAPI Rewrite.
Вы должны поместить это в файл httpd.ini веб-сайта.
# Convert http://example.com to http://www.example.com/
RewriteCond Host: ^example.com
RewriteRule (.*) http\://www\.example.com$1 [I,RP]
# Assuming we have limited number of shared folders.
# We will execute them accordingly regardless of the subdomain.
# Example: http://sub1.example.com/img/logo.jpg -> /img/logo.jpg
# Example: http://www.example.com/img/logo.jpg -> /img/logo.jpg
RewriteRule (/css/.*) $1 [I,O,L]
RewriteRule (/js/.*) $1 [I,O,L]
RewriteRule (/img/.*) $1 [I,O,L]
#Redirect all other subdirectories not matching
#to the list above as subdomains
#example: www.example.com\sub1 -> sub1.example.com
RewriteCond Host: www\.example\.com
RewriteRule /(\w*)/(.*) http\://$1\.example\.com$2 [I,RP]
# If the web site starts with www then point the file to the root folder
# If you specifically created a folder /www/ then you can comment out this section.
RewriteCond Host: (?:www\.)example.com
RewriteRule (.*) $1 [I,O,L]
# Any web site starts other than www will be re-mapped to /<subdomain>/
# Example: http://sub1.example.com/default.asp -> /sub1/default.asp
# Note: if the folder does not exists, then the user will get a 404 error automatically.
RewriteCond Host: (.*)\.example.com
RewriteRule (.*) /$1$2 [I,O,L]
#Fix missing slash char on folders
#This has to be at the end because if invalid dir exists,
#we should show 404 first
RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,RP]
Важнейшей частью является вот эта:
# Any web site starts other than www will be re-mapped to /<subdomain>/
# Example: http://sub1.example.com/default.asp -> /sub1/default.asp
# Note: if the folder does not exists, then the user will get a 404 error automatically.
RewriteCond Host: (.*)\.example.com
RewriteRule (.*) /$1$2 [I,O,L]
Это лучший способ, который я мог найти. Если у вас нет доступа к серверу и не установлен ISAPI, то это не для вас.