您需要知道如何根据以下方案修改htaccess文件。
转换此localhost / site1 / viewUser?selectedSearchedUsername = user1
类似于localhost / site1 / viewUser / user1
我目前在htaccess中使用下面的代码片段来隐藏php扩展并且它工作正常。但是仍然没有运气隐藏在url中获取变量如上所述
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
感谢名单..
答案 0 :(得分:0)
从
转换此HTTP请求http://localhost/site1/viewUser?selectedSearchedUsername=user1
到
http://localhost/site1/viewUser/user1
您只需使用
即可RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/site1/viewUser/(.*) /site/viewUser?selectedSearchedUsername=$1 [L]
此处[L]
表示这是最后一条规则。您可能会小心,并希望在您允许匹配的内容中更具限制性。例如,如果用户名只是ascii字母和数字的序列,您可以捕获它,或者您可以清除程序中的字母。小心不要让门打开。