【问题标题】:ISAPI_Rewrite Version 3 get all query string parametersISAPI_Rewrite Version 3 获取所有查询字符串参数
【发布时间】:2013-11-23 14:10:32
【问题描述】:

我有一个给定的网址:

http://www.simtalltd.com/hebrew/index.php?option=com_content&task=view&id=15&Itemid=29

我需要得到所有字符串之后:http://www.simtalltd.com/

像这样: hebrew/index.php?option=com_content&task=view&id=15&Itemid=29

我试过这段代码:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.asp?rewrite_url=$1 [QSA,L,NU]

但我只是得到:hebrew/index.php

什么是正确的代码?

【问题讨论】:

  • 检查所有查询参数。您将在index.asp 中获得所有查询参数
  • 我需要把它们都放进去:rewrite_url not as parameters
  • 这意味着我会得到它们:rewrite_url='hebrew/index.php?option=com_content&task=view&id=15&Itemid=29'

标签: .htaccess mod-rewrite url-rewriting isapi-rewrite


【解决方案1】:

平安无事!尝试使用:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+))$
RewriteRule .* /index.asp?rewrite_url=%1 [NC,QSA,L,NU]

或者您可以尝试分别匹配请求正文和查询字符串:

重写引擎开启

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule (.+) /index.asp?rewrite_url=$1\?%1 [NC,QSA,L,NU]

【讨论】:

  • 感谢您的帮助,但很抱歉,两者均无效。第一个返回错误:第 22 行上的未知表达式:RewriteCond %{REQUEST_URI} ^/(.+))$ 第二个返回只是:'hebrew/index.php?option=com_content' 仍然缺少完整的字符串:' hebrew/index.php?option=com_content&task=view&id=15&Itemid=29'
  • 哦,这是括号中的错字:RewriteCond %{REQUEST_URI} ^/(.+)$
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-09
  • 2021-12-23
  • 1970-01-01
  • 2021-05-24
  • 1970-01-01
相关资源
最近更新 更多