views:

64

answers:

3

I have a test site. I want the user to be able to logoff, but it looks ugly to go to: 'localhost/site/index.php?logoff=y'. I'm a newby at PHP, and it's probably pretty obvious how to do this, but...

How would I do this? I want the logoff link to go to 'localhost/site/logoff' Any help appreciated. Thanks

+4  A: 

The keyword you are looking for, if your site is running Apache, is mod_rewrite. Those are URL rewriting commands you usually place in a .htaccess file in your web site folder. See for example this tutorial.

The official Apache documentation is, of course, the ultimate reference but a bit harder to chew. Before starting to fiddle with mod_rewrite, make sure your provider / server has mod_rewrite enabled.

Pekka
+6  A: 

This is usually done via mod_rewrite. Take a look at the Apache Documentation and for examples and a beginners page modrewrite.com.

Best wishes, Fabian

halfdan
Thanks, both of you! That was really quick! I'll take a look at those.!
Rob Martineau
A: 

This can also be accomplished in the .htaccess file with the ForceType directive.

If you created a file called "site", then put a .htaccess file in that directory

<Files site>
        ForceType application/x-httpd-php
</Files>

Apache would treat site as if it were a php document, and requests to /site/blah would be routed to it.

preinheimer