This is a discussion on beginner - rewriting URLs from ?p= within the PHP General forums, part of the PHP Programming Forums category; I am using PHP on my first site and am trying to figure out how to get the server to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am using PHP on my first site and am trying to figure out how to get
the server to rewrite the URLs before I put it online. The testing folder that contains my new PHP files is at www.thesouthbeachhostel.com/on-hold/index.php. The original site at www.thesouthbeachhostel.com is just regular HTML with no PHP includes. In the final site I want the URLs to look like this: www.thesouthbeachhostel.com/hostel-links.com instead of like this: http://www.thesouthbeachhostel.com/i...p=hostel-links. This is important because I have other outside links already pointing to those pages. I found the following article online (I attached the relevant parts below). It is a little beyond me and I was wondering if someone could offer a little assistance. I don't want a folder like http://www.thesouthbeachhostel.com/h...stel-links.com -- I just want it to be as so: the future page http://www.thesouthbeachhostel.com/i...?p=rooms-rates should become www.thesouthbeachhostel.com/rooms-rates.htm Thanks in advance for any help people can offer. I can't understand everthing in the following article. How do I make it do what I want? How does one log into the server to make Linux commands? --------------------------------------------------------------- Excerpt from Dan Zarrella 2003 Stargeek Studios http://www.stargeek.com Making dynamic pages look static without mod_rewrite A way to mask bulky dynamic page URLs (and avoid the question mark delay) is Apache's ForceType in combination with a PHP command to interpret URLs like: www.example.com/books/computers.html as referring to a page called "books" which is executed as a PHP script (I usually make a link on the linux server from "books.php" to "book" to make editing the script easier). The function will return an array of the additional values, including the category "computers". This can be accomplished by inserting a line like this into the ..htaccess file in the root of your web documents directory: <Files *Directory Handle Name Here*> ForceType application/x-httpd-php </Files> *Directory Handle Name Here* should be replaced with the alias name you are giving to the fake directory you are creating. In this example: www.example.com/books/computers.html your .htaccess line would look like this: <Files books>ForceType application/x-httpd-php</Files> You can then log into your server and create a link to the file "books" or whatever directory alias you have choosen. This is done with the linux command "ln", or link, like this: $ Ln books.php books This creates a link between the existing PHP script books.php and the non-existant "books". This way all requests for the directory "books" will be given to books.php, ie www.example.com/books/computers.html would be handled by books.php Inside books.php you can use this function (available here) to extract values from the static-looking request URI's: |