-1

我有如下所示的链接:

http://localhost/account/index.php?key=changepassword
http://localhost/account/index.php?key=changeemail

http://localhost/library/index.php?key=nemesis
http://localhost/library/index.php?key=books

我怎么能将它们重写为:

http://localhost/account/changepassword
http://localhost/account/changeemail

http://localhost/library/nemesis
http://localhost/library/books
4

1 回答 1

0

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(account)/(.+?)/?$ /$1/index.php?key=$2 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(library)/(.+?)/?$ /$1/index.php?key=$2 [L,QSA,NC]
于 2013-06-07T04:22:01.507 回答