Assume that the first-level domain name is taobao.com
Each store has a second-level domain name. There is a store called Baobao, and its domain name is baobao.taobao.com
Each store is accessed through the second-level domain name and redirected to taobao.com/shop/baobao
That is to say, there are a large number of stores, and each store has a second-level domain name. Assume that the domain name is xxx.taobao.com
Need to redirect to taobao.com/shop/xxx
The *A records of DNS all point to this machine.
If it is implemented using apache mod_rewrite, how to write the configuration?
Are there any other ways?
Nginx is probably written like this:
Apache is similar to:
Purpose
) /test/$1$2 #/test is the directory behind www.test.com/
When accessing abc.test.com jumps to www.test.com/test/abc, the browser address will display the abc.test.com address.
Method
Add a new virtual host to the apache configuration file
NameVirtualHost :80
ServerName www.test.com
ServerAlias *.test.com
DocumentRoot /var/www/test
rewriteengine on
rewritecond %{HTTP_HOST} [^.]+.test.com$
rewriterule ^(.+) %{HTTP_HOST}$1 [C]
rewriterule ([^.]+).test.com(.
Also, can you turn on your debug and look at the logs?
I added apache configuration:
RewriteRule ^/([-a-z0-9]+).xiaocaowangluo.com/?$ http://xiaocaowangluo.com/shop/$1/ [L]
There are two connections here http://xiaocaowangluo.com/shop/test/ http://test.xiaocaowangluo.com/ This configuration has been added.
http://test.xiaocaowangluo.com/ Still can’t jump to http://xiaocaowangluo.com/shop/test/ Do I need to add other ones?
Let me use it
RewriteEngine on RewriteCond %{HTTP_HOST} ^[^.]+.xiaocaowangluo.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+).xiaocaowangluo.com(.*) /www/xiaocaowangluo/shop/$1$2
This configuration doesn’t work either, please help me.
apache can be written like this
Appconfig:
http://www.aips.me/sae-binding-domain-subdirectory.html