apache url mapping way to confusing

Discussion in 'Apache' started by bandito40, Mar 28, 2008.

  1. #1
    Hi,

    I have found myself having to use URL mapping in Apache but from the examples and tutorials I read, I am still very confused. I still am not even sure where to put the .htaccess file.

    Here's what I am trying to do. I am am downloading certain pages from the internet ans saving them locally with a program that I wrote in PHP. This programs is in the folder /one/two and saves pages to /one/two/three. My problem is when I load a locally saved page, any relative links that start with '/' resolve by remove the path /one/two/three. For example the url '/styles/main.css' load from a page save locally as /one/two/three/index.php. results in a url that looks as such 'http://localhost/styles/main.css'. I can just save the css file to the root folder but then it would be mixed in other program files. Files such as index.php in my root could be replaced with some other index.php and ruin my website. What I would like to do is have the '/' or rather '/(.*)' redirect to the folder /one/two/three where I have the data saved.

    My first problem is I don't know if I should have .htaccess saved in the root or where the the web page is locally saved. I tried saving it just about everywhere in the path but no luck.

    My second problem is of course is that I am not sure how to actually do the rewrite. This is the code that I saved to .htaccess.

    RewriteEngine on
    RewriteRule ^/(.*)$ /one/two/three

    And lastly, does the apache server have to be restarted each time I create a .htaccess file.

    Thanks,


    Carl


    http://www.gaihosa.com
     
    bandito40, Mar 28, 2008 IP