daanoz Posted December 29, 2009 Share Posted December 29, 2009 hey People I got a question about creating a virtual directory link with .htaccess Imagine my dir-structure as follows: /www/vhosts/domain.com/httpdocs/.htaccess /www/vhosts/domain.com/httpdocs/index.php /www/vhosts/domain.com/php/virtdocs/index.php /www/vhosts/domain.com/php/virtdocs/style.css I configured my vhost as using the httpdocs directory as the root directory for domain.com, want I want is that when domain.com/virt/index.php, apache returns the file in the virtdocs directory, which is outside of the httpdocs directory. Currently I got this working in a subdir at my (windows)localhost RewriteRule ^virt(.*?)$ ../php/virtdocs$1 [NC,L,NE,PT] But this gives me the following error on my linux vhost: [Tue Dec 29 12:07:52 2009] [error] [client 195.241.119.125] Invalid URI in request GET /virt/style.css HTTP/1.1 So my question is how to solve this problem. Thanks! Daanoz PS. I'd rather not use an absolute path like /www/vhosts/domain.com/php/virtdocs/ because this would make it more difficult to install on other systems Quote Link to comment https://forums.phpfreaks.com/topic/186582-virtual-directory-in-parent-directory/ Share on other sites More sharing options...
cags Posted December 29, 2009 Share Posted December 29, 2009 You could perhaps use Alias so that the whole path would only need to be changed in one place... Alias /virt /www/vhosts/domain.com/php/virtdocs/ Quote Link to comment https://forums.phpfreaks.com/topic/186582-virtual-directory-in-parent-directory/#findComment-985374 Share on other sites More sharing options...
daanoz Posted December 29, 2009 Author Share Posted December 29, 2009 Hmm, this does what I want... but it does require access to my apache configuration (or vhost configuration), which in my case I have, but on my some of my other boxes I don't... Isn't there a way to simulate it with a .htaccess? Daan Quote Link to comment https://forums.phpfreaks.com/topic/186582-virtual-directory-in-parent-directory/#findComment-985388 Share on other sites More sharing options...
cags Posted December 29, 2009 Share Posted December 29, 2009 It may be achievable with RewriteBase, I'm not sure what directory is returned using RewriteBase "/" but I've got a feeling it's probably DocumentRoot, which by the sounds of it won't help. Quote Link to comment https://forums.phpfreaks.com/topic/186582-virtual-directory-in-parent-directory/#findComment-985407 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.