Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

apache - Different folder as website subfolder

I need some help with URL rewriting. The case is similar with this one.

I have a working Zend Framework site. Now I must add a blog in Wordpress (also working). I've chosen not to indulge in ZF controller-/action-/route-making; I've seen a couple of tutorials about this and I consider them too much for a "plain" redirection. Now, about that "redirection"...

This is how it should look like:

  • www.site.com (points to /var/www/zf)
  • www.site.com/blog (points to /var/www/wp)

I know that I should stop www.site.com/blog to enter ZF's innards and I'm currently doing this with RewriteRule ^blog - [NC,L] in its .htaccess, but that's about it. As @jason said, "just pass it through to Wordpress", but I don't know how exactly to do that.

Related question:
I never tried it, but does Apache support this in two different vhosts?
ServerName www.site.com (vhost for ZF site)
ServerName www.site.com/blog (vhost for WP site)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

www.site.com (points to /var/www/zf)

www.site.com/blog (points to /var/www/wp)

The easiset way to achive this, where you want a sub-url to point outside the VirtualHost's DocumentRoot directory, is to create an Alias...

Inside the VirtualHost block add:

Alias /blog /var/www/wp

<Directory /var/www/wp>
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

*This assumes you have PHP enabled in some way for that directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...