Page 1 of 1

htaccess help - Path issue with files within directory

PostPosted: 21. January 2011 18:31
by nvisioncurtis
Hi All,
How can I redirect paths with a leading '/' to a folder instead of root?

I recently took over a website that has all kinds of include files. My problem is that I want to run this site locally from within a folder like so.
C:\xampp\htdocs\mywebsite
C:\xampp\htdocs\mywebsite\includes

But all the links begin with '/' so that when a template is included with say a linked css file
ex. <link rel="stylesheet" type="text/css" href="/viacom_news.css">

it correctly looks in the htdocs root folder but I need to look in root/mywebsite folder.

I don't want to edit all those links as they work on the real server. Can this be overridden with a htaccess file some how? My attempts have all failed.
Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^rewritetest/(.*) mywebsite/$1



Thanks so much for any suggestions.

C.

Re: htaccess help - Path issue with files within directory

PostPosted: 21. January 2011 23:31
by Nobbie
Simply create a VirtualHost and set the DocumentRoot to C:\xampp\htdocs\mywebsite

Re: htaccess help - Path issue with files within directory

PostPosted: 21. January 2011 23:39
by nvisioncurtis
Oh great,

How do I do that? Is that an apache thing or Htaccess?

I'm doing a search now... thanks!

Re: htaccess help - Path issue with files within directory

PostPosted: 21. January 2011 23:50
by nvisioncurtis
Hmm,
I did a quick search and found this code.
But when I plug in my directory I get a server error.
I'm not a whiz at this stuff. Any ideas?

Code: Select all
Options Includes
Options +FollowSymlinks
RewriteEngine On

<VirtualHost *:80>
  DocumentRoot C:\xampp\htdocs\news_vcom_com
  ServerName vcom
</VirtualHost>

<Directory C:\xampp\htdocs\news_vcom_com>
  Order Deny,Allow
  Allow from all
  AllowOverride All
</Directory>


Re: htaccess help - Path issue with files within directory

PostPosted: 21. January 2011 23:59
by Sharley
First of all server errors are best investigated by reading \xampp\apache\logs\error.log file that will reveal all the gory details. :)

Try and follow this topic for creating your vhost, it may help get a handle on it:
viewtopic.php?f=16&t=43109

Good luck and best wishes.

Solved!

PostPosted: 22. January 2011 00:11
by nvisioncurtis
Well I was putting the vhost in teh wrong place. goes in
C:\xampp\apache\conf\extra\httpd-vhosts.conf
Code: Select all
 <VirtualHost *:80>
  DocumentRoot C:\xampp\htdocs\mywebsite
  ServerName mywebsite
</VirtualHost>

<Directory C:\xampp\htdocs\mywebsite>
  Order Deny,Allow
  Allow from all
  AllowOverride All
</Directory>


Hope this helps someone else. Thanks!

Not Solved.

PostPosted: 22. January 2011 01:29
by nvisioncurtis
Hmm, I thought It was working... What is happening now is the root website points to the folder as desired. But none of my other websites can be accessed.

So basically my code as above roots http://locahost/ to the directory I specified but I wanted http://locahost/mywebsite rooted there.
Not what I was after. :(

My original question was how do I make paths with a preceding '/' go to the root of my subfolder in stead of the root of the webserver.
i.e. http://localhost/mywebsite => (c:\xampp\htdocs\mywebsite) and not (c:\xampp\htdocs) so that mywebsite2 and mywebsite3 are unaffected.

I'm searching around for an answer but any insights would be approeciated.

Thx.

Re: htaccess help - Path issue with files within directory

PostPosted: 22. January 2011 01:33
by Sharley
You were given the solution to your problem and I will endeavor to expand on the details of that solution for you.


Creating just one vhost if you have multiple web sites won't fix the other web sites, you have to create a vhost and a DocumentRoot for each of your web sites.


Paste your httpd-vhosts.conf file here so I can have a look at how you have entered the code and if you used the link I provided as a template then it should work just fine.
(If you have any security concerns providing details in this open forum then please PM me the details and I will walk you through to a solution).

Once you get one web site vhost working then you can create a vhost for your other web sites also by using the good and working vhost as a template for each of your other web sites.


Did you edit the Windows HOSTS file as outlined in the link I provided?