使用查询字符串

时间:2017-05-08 04:31:20

标签: php apache .htaccess

我一直在争吵几个小时试图让它做我想做的事。

我的根目录中有一个.htaccess文件,用于读取干净的URL:

#turn on url rewriting
RewriteEngine on

#remove the need for .php extention
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]

然后有一个目录/hnid,其中包含一个user.php文件,该文件接受带有id的get请求。我在/hnid文件夹中也有一个.htaccess文件:

RewriteEngine on
RewriteRule ^user/([^/\.]+)/?$ user?id=$1 [L]

我的问题在于结果。我希望能够访问/hnid/user/1a以获取第27个用户(是的,我已在文件中处理以转换ID)。

user / 1a给出404,用户?id = 1a给出404,user.php?id = 1a工作正常,user.php / 11返回此消息:

Notice: Undefined index: id in /var/www/html/hnid/user.php on line 3

我不知道该做什么,但我希望你们精彩的人能够启发我。感谢。

0 个答案:

没有答案
相关问题