【问题标题】:Slim Framework proper htaccess setup with wordpressSlim Framework 使用 wordpress 正确设置 htaccess
【发布时间】:2013-06-12 10:34:58
【问题描述】:

我想用 slim 制作一个 api。它将位于我的“工具”子域中的一个名为 api 的目录中。

http://tools.fifaguide.com/api

我的 .htaccess 文件应该是什么样的?

目前我的 .htaccess 位于我的 Wordpress 目录中(html -> .htaccess),它看起来像这样:

<IfModule mod_rewrite.c>

//my part
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/api/index.php
RewriteRule ^api/(.*) http://tools.fifaguide.com/api/index.php [L]

//wordpress part
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L]

</IfModule> 

问题是当我尝试时

 http://tools.fifaguide.com/api/hello/steve

我立即被重定向回 api/index.php,而不是停留在 /api/hello/steve 并显示结果。

似乎 wordpress 正在发生这种情况,但我该如何防止呢?

【问题讨论】:

    标签: php wordpress .htaccess mod-rewrite slim


    【解决方案1】:
    <IfModule mod_rewrite.c> 
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} ^/api/ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ api/index.php [QSA,L]
    
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L]
    </IfModule>  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-26
      • 1970-01-01
      相关资源
      最近更新 更多