$_Get 在这种特殊情况下不起作用
我正在尝试使用 http://www.example.com/news/id/21/title/top-10-things/?page=
1 用于发送页面参数,但它在下面的 php 中不起作用
是我的.htaccess 文件中的设置
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news/(.*)/(.*)/(.*)/(.*)/$ /news.php?$1=$2&$3=$4
RewriteRule ^news/(.*)/(.*)/$ /news.php?$1=$2
RewriteRule ^news/$ /news.php
I am trying to usehttp://www.example.com/news/id/21/title/top-10-things/?page=
1 for sending the page parameter and it is not working in php
below is my setting in the .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news/(.*)/(.*)/(.*)/(.*)/$ /news.php?$1=$2&$3=$4
RewriteRule ^news/(.*)/(.*)/$ /news.php?$1=$2
RewriteRule ^news/$ /news.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将
%{QUERY_STRING}
附加到 htaccess 中的网址。正如 Daniel 指出的,您还可以使用 mod_rewrite
qsappend
或QSA
标志来实现此目的。参考: http://httpd.apache.org/docs/2.0/mod/mod_rewrite .htmlTry appending the
%{QUERY_STRING}
to the URLs in your htaccess.As Daniel noted, you can also use the mod_rewrite
qsappend
orQSA
flag for this purpose. REF: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html将 QSA 标志设置为将请求的查询自动附加到替换 URL 中:
此外,如果可以更具体,则不应使用
.*
。在这种情况下,使用[^/]+
可以避免不必要的回溯:对于任意数字或参数的通用解决方案,请参阅 重写任意数量的路径段来查询参数。
Set the QSA flag to get the requested query automatically appended to the one in substitution URL:
Furthermore, you shouldn’t use
.*
if you can be more specific. In this case using[^/]+
instead avoids unnecessary backtracking:And for a general solution for an arbitrary number or parameters, see Rewriting an arbitrary number of path segments to query parameters.