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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度