htaccess的重写后的AJAX页面导航不工作重写、页面、工作、htaccess

2023-09-02 01:07:18 作者:夏日冷男

我使用的.htaccess从

i use .htaccess to rewrite my url from

/list.php?pat=free&mainCol=maincate&subCol=shoes

/ maincate /鞋

/maincate/shoes

重写后,阿贾克斯翻页按钮不工作了。它应该来自同一个文件夹中加载list_pull.php为list.php的

after rewrite, the ajax next page button is not working anymore. it should load list_pull.php from same folder as list.php

    $.post("list_pull.php",{
        pageCurrent:pageClick,      
        pullSubCol:$("#pullSubCol").val()});

和htaccess的是这样的

and the htaccess is like this

RewriteRule ^([^/.]+)/([^/.]+)$ /list.php?pat=free&mainCol=$1&subCol=$2  [L]

我想使用完整路径 http://www.mydomain.com/list_pull.php - 不工作 我试图创建一个文件夹maincate,并把listpull.php里面,仍然没有工作。

i tried use full path http://www.mydomain.com/list_pull.php - not working i tried creating a folder "maincate" and put listpull.php inside, still not working.

对了,我还有一个文件一样listpull.php,和它的作品! 重写是这样

by the way, i have another file same as listpull.php, and it works! the rewrite is like this

RewriteRule ^([^/.]+)$ /mainlist.php?pat=free&mainCol=$1  [L]

不知道如果我的问题是很清楚,一直在试图弄明白2天了,仍然没有运气。

dont know if my question is clear enough, been trying to figure it out for 2 days now, still no luck.

在此先感谢帮助!

推荐答案

您已经重定向后,域名的所有PARAMS到 mainlist.php 的URI字符串,有两个 / list.php的,所以我建议你添加的另​​一个特定的重写规则 list_pull.php 和替换的 [L] 是 [QSA]

You have redirected all the params after domain name to mainlist.php and the uri string with two / to list.php so i suggest you to add another specific rewrite rule for list_pull.php and replace [L] with [QSA]

QSA 表示,如果有通过与原来的URL查询字符串,它会被追加到重写(欧莱?P = 1 将被改写成的index.php URL =欧莱和放大器; P = 1

QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite (olle?p=1 will be rewritten as index.php?url=olle&p=1.

表示,如果规则匹配,不处理在这之下的任何更多的规则集。

L means if the rule matches, don't process any more RewriteRules below this one.

RewriteRule ^call_ajax$ /list_pull.php  [QSA]

现在在你的Ajax调用把URL像这样

Now in your ajax call put url like this

$.post("/call_ajax",{
        pageCurrent:pageClick,      
        pullSubCol:$("#pullSubCol").val()
});

修改尝试 htaccess.madewithlove.be 下面我附上一些测试重写这对我来说工作得很好,以测试你的重写规则

Edit Try htaccess.madewithlove.be to test your rewrite rules below i have attached some test rewrites which works fine for me

1) http://www.example.com/call_ajax 为重写规则^ call_ajax $ /list_pull.php [QSA]

2) http://www.example.com/call/ajax 要重写规​​则^([^ /] +)/([^ /] +)$ /list.php?pat=free&mainCol=$1&subCol=$2 [QSA]

2) http://www.example.com/call/ajax to RewriteRule ^([^/.]+)/([^/.]+)$ /list.php?pat=free&mainCol=$1&subCol=$2 [QSA]

3) http://www.example.com/call 以重写规则^( [^ /] +)$ /mainlist.php?pat=free&mainCol=$1 [QSA]

3) http://www.example.com/call to RewriteRule ^([^/.]+)$ /mainlist.php?pat=free&mainCol=$1 [QSA]