dongzhi9906 2012-12-19 22:09
浏览 27
已采纳

如何不包括来自AJAX POST调用的文件的htaccess重定向

I have a htaccess file like so

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.*)$ /us/index.php?state=$1&city=$2 [L]

I have a file called getuser.php which is a php file that gets called from an AJAX call in the index.php. If i dont use a redirect the call works fine, but because of the redirect I have it interfering with the AJAX call and redirecting the getuser.php call as well from the post which just results in displaying the index.php file again on top of my current page. Is there a way to not have the redirect not inter fear with the AJAX call so it can simple display my results on my page without compromising the current redirect.

I tried to add the following which just causes the AJAX to break and not work since it is not allowuing the call to be made to the getuser.php file. Any help would be apprechiated please.

RewriteCond %{REQUEST_URI} !/getuser\.php
  • 写回答

1条回答 默认 最新

  • doufei2355 2012-12-19 22:17
    关注

    Try this, the L flag should tell apache this is the last rule and to just go to the requested url.

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/getuser\.php$ $0 [L]
    RewriteRule ^([^/]+)/(.*)$ /us/index.php?state=$1&city=$2 [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图