Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different folder as website subfolder

Tags:

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)

like image 642
nevvermind Avatar asked Jun 10 '11 13:06

nevvermind


People also ask

How do I create a sub folder for my website?

Make a subdirectory in your WWW root dir that can be accessed by the user that your webserver runs under with the name that you want to put after your domain (ex: www.mysite.com/thisisthedirnameyouuse/afile.html ), and put the files in there. Ryan J means 'make a new folder' when he says 'subdirectory'.

What is better subdomain or subdirectory?

The subdirectory strategy concentrates your keywords onto a single domain while the subdomain strategy spreads your keywords across multiple distinct domains. In a word, the subdirectory strategy results in better root domain authority.

Is a subdomain a separate website?

A subdomain is very different from a subdirectory; it is like an entirely different website. The subdomain is associated with the domain, but not the website that is associated with the domain name. A subdomain is generally considered as a standalone site that is branched off from the main domain.


1 Answers

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.

like image 189
rightstuff Avatar answered Sep 17 '22 13:09

rightstuff