Can I do use a direct URL like twitter or myspace

2019-05-10 16:27发布

问题:

Can I do that thing that twitter and many other sites do where a url shows a users page.

www.mysite.com/the_user_name

In php... or how does one do it?

回答1:

Look into how to use the mod_rewrite module in .htaccess.

Here's some ALA goodness:

  1. How to Succeed With URLs
  2. URLS! URLS! URLS!


回答2:

The easiest method would be to use mod_rewrite in Apache (as opposed to doing it in PHP). Here's a good beginner's guide.



回答3:

The easiest way that I know of is to create a .htaccess file for the website with the RewriteEngine turned on.

For example

RewriteEngine On

RewriteRule ^(.+) /index.php?user=$1

Do a google search for .htaccess and RewriteEngine to get a better grasp of the process or creating an .htaccess file.



标签: php html url