doushi1996
2014-02-23 01:30
浏览 110
已采纳

XAMPP + .htaccess - 重写不起作用

So I have the following structure :

xampp/htdocs/project/
xampp/htdocs/project/index.php
xampp/htdocs/project/api/index.php

and the following .htaccess :

RewriteEngine on
RewriteRule ^api/.* /api/index.php [NC,QSA,L]

I believe that what this is saying is to redirect whatever request under api/ to api/index.php.

An AJAX request for api/ brings me the results of api/index.php
An AJAX request for api/user gives me a 301 and then the directory tree of api/user/
An AJAX request for api/user/ gives me a 404.

I then commented out the lines of the .htaccess and the same thing happened. As if it didn't make any difference that the file was there.

What could be wrong? My .htaccess is under xampp/htdocs.
I've been fiddling about with this for about 3 hours and it's driving me crazy.

图片转代码服务由CSDN问答提供 功能建议

所以我有以下结构:

xampp / htdocs /项目/ 结果, <代码> XAMPP / htdocs中/项目/ index.php的结果, <代码> XAMPP / htdocs中/项目/ API / index.php的

以下.htaccess:

  RewriteEngine on 
RewriteRule ^ api /.* /api/index.php  [NC,QSA,L] 
   
 
 

我认为这就是将api /下的任何请求重定向到api / index.php。

api /的AJAX请求给我带来api / index.php的结果
api / user的AJAX请求给我一个301然后是api / user / 对api / user /的AJAX请求给了我一个404.

然后我注释掉了.htaccess的行,发生了同样的事情。 好像文件没有任何区别。

可能有什么问题? 我的.htaccess位于 xampp / htdocs 之下。
我已经花了大约3个小时的时间来摆弄这个并且它让我发疯了。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtqpw68806 2014-02-23 02:02
    已采纳

    Place your .htaccess in the root of your project, not in htdocs.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题