dongwen2896 2015-06-23 10:13
浏览 23
已采纳

如何为AJAX页面编写.htaccess文件

I am working on a website which i am going to develop as a CMS. So i am writing .htaccess file. page link and url working fine, but when i performing ajax request then i am getting 404 error for the url. I am placing my .htaccess file code and the ajax request which i am calling.

.htaccess file

RewriteRule ^single _single_Page.php [NC,L]
RewriteRule ^single/([A-Za-z0-9-]+)/?$ _single_Page.php?subid=$1 [NC,L]
RewriteRule ^findcontents/([A-Za-z0-9-]+)/?$ _findContentTitle.php?data=$1 [L,QSA]

AJAX request using JQuery

$('.search').keyup(function(e){
    var data=$(this).val();
    data="data="+data;
    $.ajax({
        url:'/findcontents',
        type:'POST',
        data:data,
        success:function(result){
            if(result==""){
                $('.result p').html("No result found.<br>Please make correct search.");
            }else{
                $('.result p').html(result);
            }
            $('.result').css('visibility','visible');
        },
        error:function(error){console.log(error);}
    });

});

Please friends tell me where i am wrong, as i need to fix it out as soon as possible.

Thanks....

  • 写回答

1条回答 默认 最新

  • douxingmou4533 2015-06-23 10:47
    关注

    I think it's more related to apache than ajax. Anyway - your RewriteRule is ^findcontents/([A-Za-z0-9-]+)/?$ and you post to the url '/findcontents'. Did you try to post to '/findcontents/asdf' ? Another option is to add ^findcontents$ to your rules.

    If none of these works for you please provide some more information from the server's log.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器