.htaccess 对子域名感到沮丧
在Zend框架下,我有一个像这样的目录结构:
索引:/domains/example.com/public_html/public/index.php
博客索引:/ domains/example.com/public_html/blog/index.php
在我的 .htaccess 文件中,下面显示的是指向主页的部分 - 这工作正常:
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]
我已经在我的主机管理控制面板中启用了一个子域,并且现在我想添加一个可通过以下方式访问的博客:blog.example.com
我尝试添加:
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]
但这在导航到 blog.example.com 时会产生可怕的“内部服务器错误 - 500”,例如.com/blog 甚至 example.com..
我怀疑这可能是 Zend Framework 的复杂性导致的。 我应该在 .htaccess 中添加/编辑什么以使 blog.example.com 正确指向?
请&谢谢。
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 piece 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你需要使用这个
这会将你所有的 blog.example.com 流量重写到 example.com/blog
I think you need to use this
This will rewrite all your blog.example.com traffic to example.com/blog