douyue4334 2016-10-14 23:42
浏览 20
已采纳

Htaccess如何在特定目录中不重定向到root

I have the following code in my htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !_assets/ajax
RewriteRule !^index\.php$ index.php [L]

I thought and hoped this would exclude the _assets directory from being redirected to the root, but without success.

All directories are being redirected to the root, where I explode the URI to get the respective pages (in PHP). The htaccess file is actualy working as the right content is being displayed, according to the uri.

So to be briefly, my ajax calls do not work because of this.

How can can I make this work?

I'm using WAMP and created a virtual host named http://project.localhost.

  • 写回答

1条回答 默认 最新

  • drll42469 2016-10-15 10:40
    关注

    The easiest way to handle this is with a simple rewrite rule that you put before any other rewrite rules.

    RewriteRule ^/_assets/ajax/ - [L]
    

    It say to take every URL that matches the regex ^/_assets/ajax/ (that is, everything in that directory), don't rewrite it, and stop processing the .htaccess file.

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

报告相同问题?

悬赏问题

  • ¥15 找一个QT页面+目标识别(行人检测)的开源项目
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败
  • ¥15 用Ros中的Topic通讯方式控制小乌龟的速度,走矩形;编写订阅器代码
  • ¥15 LLM accuracy检测
  • ¥15 pycharm添加远程解释器报错
  • ¥15 如何让子窗口鼠标滚动独立,不要传递消息给主窗口