doujianqin5172
2018-04-05 18:07
浏览 69
已采纳

.htaccess重写GET参数

I would like to change my URL from site.com/functions/analyze.php?password=test to site.com/functions/analyze/password/test. I am using a .htaccess rewrite rule in attempt to achieve this.

However, upon browsing to my /functions/analyze/password/test I can see that the GET parameter being passed is test.php/password/test and not test.

Where am I going wrong?

# Enable editing.
Options -MultiViews
RewriteEngine On

# Hide PHP extenstion.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

# Reroutes for GET.
RewriteRule ^(functions/analyze)/(password)/(.+)$ $1.php?$2=$3 [L,NC,QSA]

图片转代码服务由CSDN问答提供 功能建议

我想从 site.com/functions/analyze.php?password=test更改我的网址 site.com/functions/analyze/password/test 。 我正在使用.htaccess重写规则来尝试实现此目的。

但是,在浏览到我的 / functions / analyze / password / test 后,我可以看到 传递的GET参数是 test.php / password / test 而不是 test

我哪里出错?

 #启用编辑。
Options -MultiViews 
RewriteEngine On 
 
#隐藏PHP扩展。
 
RewriteEngine on 
RewriteCond%{REQUEST_FILENAME}!-d 
RewriteCond%{REQUEST_FILENAME}  \ .php -f 
RewriteRule ^(。*)$ $ 1.php 
 
#重新获取GET。
RewriteRule ^(函数/分析)/(密码)/(。+)$ $ 1.php?$ 2 = $ 3  [L,NC,QSA] 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题