开发者

How to use multiple files in a php webpage

I am creating a webpage with PHP/MySQL, and each page is in its own .php file.

How should I organize the addressbar, when changing the viewing page?

I have thought of two different ways to solve this:

1) www.mywebpage.com/?page=REFERENCES+pageid=GUID_TO_USE_FOR_DB_LOOKUP

2) www.mywebpage.com/references.php?GUID_TO_USE_开发者_C百科FOR_DB_LOOKUP

Which should I choose? Are there other ways to do this?

Edit: When the user clicks a link to another page, I want to redirect the user to the corresponding .php file. The question is how to show this in the addressbar in the web browser.

With the GUID_TO_USE_FOR_DB_LOOKUP, I want to pass parameter to the .php file


Another way to do it:

www.mywebpage.com/references/GUID.html

You can use mod_rewrite to use URLs like this and have them mapped to "references.php?GUID=xyz" internally.

However, all solutions are fine and will work the same way (display the page), the advantage of the above is just that the URL is more "readable" as well as better for search engine optimization as the URL-"path" is parsed by search engines (other than using parameters).

Search for "mod_rewrite SEO" to find out more about this topic, e.g.:
http://www.htmlist.com/how-to/a-simplemod_rewrite-tutorial/

A couple of questions to ask:
Why do you care about the URL? Should it be human readable? Do you care about SEO? Do you like to use a "framework" with a single point of entry (which could work like your first example)? Do you want to "hide" your actual filenames from your users? etc. etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜