如何管理与分页上的.htaccess缩短搜索结果 [英] How to manage search result with pagination on .htaccess shortening
问题描述
下面哪个是对PHP语言开发的应用程序。
Here on the application which is developed on php language.
问题上分页,有三个变量(PAGE,refone,reftow)
the problem is on pagination, there is three variables(PAGE, refone ,reftow)
不是形式将是这样的:
<from>
<input type=text name=refone>
<input type=text name=reftow>
<input type=submit value=search name=search>
</from>
在用户提交搜索会导致,
as the user submit search it will result,
例如 - > refone = 1和reftow =任何
for example the -> refone = 1 and reftow = any
in the actual url = ?page=1&refone=1&reftow=% ... this works
with .htaccess url = ?page/1/1/% ... not works
现在因为有搜索(refone&LT; - > reftow)拖选项(refone - >任意)(任意&LT; - reftow)基本上它与正常的URL的工作,但是当我使用的.htaccess为使其短不要让用户知道确切的URL的工作,所以我用波纹管的.htaccess更好的固定和URL管理就像缩短。
now as there is tow option for search (refone <-> reftow) (refone -> any) (any <- reftow) basically it's working with normal url, but when I use .htaccess for making it short and do not let user to know the exact url job so I use bellow .htaccess for better securing and url management like shortening.
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule . - [L]
RewriteRule ^sref/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+) sref.php?page=$1&refone=$2&reftow=$3 [L,NC]
RewriteRule ^sref/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+) sref.php?page=$1&refone=$2 [L,NC]
RewriteRule ^sref/([-a-zA-Z0-9]+)/?$ sref.php?page=$1 [L,NC]
现在的情况:
http://m.lhost/web/sref.php?page=1&refone=1&reftow=%
http://m.lhost/web/sref.php?page=1&refone=%&reftow=1
http://m.lhost/web/sref.php?page=1&refone=%&reftow=%
它的工作原理,甚至当我使用分页像2,3页...它会工作,但使用.htacess后
it works and even when I use pagination like page 2,3... it will work but after using the .htacess
http://m.host/web/sref/1/1/%
http://m.host/web/sref/1/%/1
http://m.host/web/sref/1/%/%
在这里不能罚款的网址。 注:这里经过搜索,它会根据搜索的结果,这与在这里进行的.htaccess工作正常,但如果我使用.htacess有问题
here it can not fine the url. Note: here after search, it will use pagination based on search result, which here with out .htaccess working fine but if I use .htacess having problem.
在此先感谢任何样的建议。
thanks in advance for any kind of advice.
推荐答案
您必须添加%
来允许的字符列表,也是你的重写规则应该从网络/ SREF /...
You must add that %
to the list of allowed characters, also your RewriteRule should start with web/sref/...
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule . - [L]
RewriteRule ^web/sref/([A-Za-z0-9_-]+)/([\%A-Za-z0-9_-]+)/([\%A-Za-z0-9_-]+) sref.php?page=$1&refone=$2&reftow=$3 [L,NC]
RewriteRule ^web/sref/([A-Za-z0-9_-]+)/([\%A-Za-z0-9_-]+) sref.php?page=$1&refone=$2 [L,NC]
RewriteRule ^web/sref/([-a-zA-Z0-9]+)/?$ sref.php?page=$1 [L,NC]
这篇关于如何管理与分页上的.htaccess缩短搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!