如何在PHP中写一个干净的网址? [重复]

This question already has an answer here:

How can write a clean url from http://domain.com/details.php?users=53#People to http://domain.com/53#people/ work out i need help fellows

</div>

What you are really asking is that the request to details.php gets routed to index.php.

You will therefore need some code in index.php to understand this request is for details.

You can use this in your .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

In your index.php, you can extract the actual request and action it.

$request = substr($_SERVER['PHP_SELF'], strlen('/index.php'));