开发者

.htaccess frustration with subdomain

Under the Zend Framework, I have a directory structure like this:

Index: /domains/example.com/public_html/public/index.php

Blog index: /domains/example.com/public_html/blog/index.php

In my .htaccess file, shown below is the 开发者_如何学Gopiece that points to the homepage - this works fine:

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

I have enabled a subdomain in my host admin control panel and now I want to add a blog which is accessible via: blog.example.com

I tried adding:

RewriteCond %{HTTP_HOST} = ^www\.example\.com$
RewriteRule /blog/(.*) http://blog\.example\.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} = ^blog\.example\.com$
RewriteRule ^.*$ /blog/index.php [L]

but this produces a dreaded "Internal Server Error - 500" when navigating to blog.example.com, example.com/blog and even example.com..

I suspect that it could be a complication with the Zend Framework that's causing grief. What should I add / edit in .htaccess for blog.example.com to point correctly ?

Please & thank you.


I think you need to use this

RewriteCond %{HTTP_HOST} blog\.example\.com
RewriteRule (.*) http://www.example.com/blog%{REQUEST_URI} [NC,L,RSA]

This will rewrite all your blog.example.com traffic to example.com/blog

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜