RE: [PHP] URL modification
| From: | Xavier de Lapeyre | Date: | Mon, 25 Feb 2008 04:53:36 +0000 |
| Subject: | RE: [PHP] URL modification | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-270024@lists.php.net to get a copy of this message | ||
thnks
Xavier
Please consider the environment before printing this mail note.
-----Original Message-----
From: Nathan Rixham [mailto:nrixham@gmail.com]
Sent: vendredi 22 février 2008 18:58
To: php-general@lists.php.net
Subject: Re: [PHP] URL modification
Richard Heyes wrote:
>> Hmmmm... made a quick look into it.
>> Seems to be apache compatible.
>> I'm designing a site to be hosted on an IIS Server.
>>
>> Does it still works there?
>
> On IIS I belive the default document is default.htm Though you should be
> able to modify this to whatever you please. On Apache it is index.html
> or index.php (for example). Regardless you want this to be parsed by
> PHP, and then you can stick the following in it:
>
> <?php
> header('http://www.example.com/login.php');
> ?>
>
> Place this file in your "login" directory and then you'll be able to
> publish URLs such as http://www.example.com/login The trailing
> slash is
> not necessary if login is a directory. For example:
>
> http://www.websupportsolutions.co.uk/demo
>
To use url's like http://domain.com/login/ as opposed to
http://domain.com/login.php you can take multiple
approaches.
The first and simplest is to simply save your login.php as /login/index.php
to use this approach you need to ensure that index.php is listed as a
default page.
In IIS you can set the "default" page(s) to be whatever you like:
-> Open IIS Manager
-> Server -> Websites -> Right Click [properties]
-> select "Documents" tab
-> ensure "Enable default content page" is ticked
-> ensure "index.php" is listed
-> if not then click [add] and enter index.php
-> continue to add any other default pages [index.html, index.shtml etc]
The second common solution [and I'd advise to get used to it asap] is to
use URL rewriting.
In short url rewriting involves defining "rules" which the web server
uses to direct http requests to resources on the server.
eg: direct domain.com/all_our_news to /index.php?newsitem=all
a quick intro guide can be found here:
http://www.sitepoint.com/article/guide-url-rewriting
For URL rewriting in IIS use "ISAPI Rewrite" - http://www.isapirewrite.com/
in apache use mod_rewrite
[apache1.3>] httpd.apache.org/docs/1.3/mod/mod_rewrite.html
[apache2.0>] httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Both are pretty much identical when it comes to the end rewrite rules.
Hope that helps a little
Nathan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php