我有一个URL http://localhost/index.php?user=1
。当我添加此.htaccess
文件时
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^user/(.*)$ ./index.php?user=$1
现在将允许我使用http://localhost/user/1
链接。但是http://localhost/index.php?user=1&action=update
我该怎么做呢http://localhost/user/1/update
?
另外我该如何做这个网址http://localhost/user/add
?谢谢。对不起,我还比较陌生.htaccess
。
感谢您的想法@denoise和@mogosselin。也可以使用@stslavik指出我的代码示例的某些缺点。
这是我的方法:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^user/([0-9]*)/([a-z]*)$ ./index.php?user=$1&action=$2
RewriteRule ^user/([a-z]*)$ ./index.php?user&action=$1
通过使用我得到var_dump($_GET);
的链接localhost/user/1234/update
array (size=2)
'user' => string '1234' (length=4)
'action' => string 'update' (length=3)
而 localhost/user/add
array (size=2)
'user' => string '' (length=4)
'action' => string 'update' (length=3)
这是我的目标。我只会使用PHP进行其他操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句