开发者

htaccess point sub domain to folder

Hello how can I point some sub domain to some folder via htaccess.

I used this to point, and it works, but I can't get it working for other sub domain..

RewriteCond %{HTTP_HOST} !^www\.example.org
RewriteCond %{HTTP_HOST} some1\.example.org
RewriteRule ^(.*)$ /some1_folder/index.php/$1
RewriteRule ^some1$ /some1_folder/index.php/$1

http://some1.example.org/Content => http://example.org/some1/index.php/Content

If I make it:

RewriteCond %{HTTP_HOST} !^www\.example.org
RewriteCond %{HTTP_HOST} some1\.example.org
RewriteRule ^(.*)$ /some1_folder/index.php/$1
RewriteRule ^some1$ /some1_folder/index.php/$1

RewriteCond %{HTTP_HOST} !^www\.example.org
RewriteCond %{HTTP_HOST} some2\.example.org
RewriteRule ^(.*)$ /some2_folder/index.php/$1
RewriteRule ^some2$ /some2_f开发者_如何学运维older/index.php/$1

I get 500 internal error.

Also how can I point all non-existing domains to some folder (foo.example.org => www.example.org), too.Thanks.


Make a single set of rules for all subdomains by using %1 in the RewriteRule to grab a bracketed value from the previous RewriteCond.

RewriteCond %{HTTP_HOST} !^www\.example\.org
RewriteCond %{HTTP_HOST} ^(.*)\.example\.org
RewriteRule ^(.*)$ http://www.example.org/%1/index.php/$1

To redirect all non-existing subdomains to a domain, create a catch-all VirtualHost block at the end of the virtual host configuration file containing ServerAlias * to match any undefined domains, and a RewriteRule that forwards all requests to the domain you want to be default.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜