Re: URL modification
| From: | Nathan Rixham | Date: | Fri, 22 Feb 2008 14:58:03 +0000 |
| Subject: | Re: URL modification | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269860@lists.php.net to get a copy of this message | ||
Richard Heyes wrote:
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 NathanHmmmm... 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: <?phpheader('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