开发者

Difficult .htaccess question

I have the following directory structure:

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

Below is the .htaccess script that enables www.example.com to show the homepage which 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]

Now I want to add a blog which is accessible via a subdomain and 开发者_Go百科a directory like this: blog.example.com and www.example.com/blog.

The blog index is located here: /domains/example.com/public_html/blog/index.php

What should I add to htaccess to enable this?

I tried:

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

but the index or any other test file can't be viewed. blog.example.com produces a "real" 404 error and www.example.com/blog displays our "friendly" 404 page that Zend uses. What am I doing wrong?


You should not make a single blog accessible at two domains, because this leads to doublicate content what is not seo friendly.

It would be better if you just rewrite one uri with a 301 status to the other one.

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

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

Tell me if this worked for you. I think the second rule should not conflict with the first one due to the RewriteCond. Anyway, I am just trying to help. I have not tested this. If it does not work the 1st try, plz do not vote me down :)

peace!

EDIT: In this example I used blog.somedomain.de as the only possible address for your blog. somedomain.de/blog/ will be redirected to blog.somedomain.de

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜