htaccess help - Path issue with files within directory

Problems with the Windows version of XAMPP, questions, comments, and anything related.

htaccess help - Path issue with files within directory

Postby nvisioncurtis » 21. January 2011 18:31

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.
nvisioncurtis
 
Posts: 7
Joined: 05. January 2011 04:17

Re: htaccess help - Path issue with files within directory

Postby Nobbie » 21. January 2011 23:31

Simply create a VirtualHost and set the DocumentRoot to C:\xampp\htdocs\mywebsite
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: htaccess help - Path issue with files within directory

Postby nvisioncurtis » 21. January 2011 23:39

Oh great,

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

I'm doing a search now... thanks!
nvisioncurtis
 
Posts: 7
Joined: 05. January 2011 04:17

Re: htaccess help - Path issue with files within directory

Postby nvisioncurtis » 21. January 2011 23:50

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>

nvisioncurtis
 
Posts: 7
Joined: 05. January 2011 04:17

Re: htaccess help - Path issue with files within directory

Postby Sharley » 21. January 2011 23:59

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.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Solved!

Postby nvisioncurtis » 22. January 2011 00:11

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!
nvisioncurtis
 
Posts: 7
Joined: 05. January 2011 04:17

Not Solved.

Postby nvisioncurtis » 22. January 2011 01:29

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.
nvisioncurtis
 
Posts: 7
Joined: 05. January 2011 04:17

Re: htaccess help - Path issue with files within directory

Postby Sharley » 22. January 2011 01:33

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?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 103 guests