开发者

How to have pages without filenames (e.g. http://localhost/site/logoff)

I have a test site. I want the user to be able to logoff, but it开发者_StackOverflow社区 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


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜