我一直在通过许多不同的方式在我的.htaccess中创建一个mod_rewrite来创建转发到特定路径的通配符子域,同时保留目录和页面的尾随URL。似乎没有什么可以做到的。我只是不太擅长正则表达式而已经弄清楚了。
我的通配符需要:
http://username.domain.org/project1/hello.html
与:
相同http://domain.org/domains/username/project1/hello.html
有什么想法吗?
答案 0 :(得分:0)
在.htaccess文件中尝试此操作:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.org$ [NC]
RewriteRule ^(.*)$ http://domain.org/%1/$1 [R=301,L]