Apache mod_rewrite

时间:2014-09-19 21:04:26

标签: php .htaccess mod-rewrite curl apache2

我有2个PHP脚本 test1.php test2.php ,这些脚本卷曲到位于相同的远程服务器上。 test1.php使用URL $ url ='http://myserver.com/api'(脚本所在的远程服务器)和 test2.php 用作网址$url = 'http://localhost/api' 。此外,我在根文件夹中有 .htaccess 文件:

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On 
</IfModule>

RewriteEngine on
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff

test1.php 的回复是:

HTTP/1.1 200 OK
Date: Fri, 19 Sep 2014 20:56:00 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PrestaShop Webservice

test2.php 的回复是:

HTTP/1.0 302 Moved
Date: Fri, 19 Sep 2014 20:57:49 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.4
location: http://myshop.com/?url=products&display=%5Bid%5D&limit=5

为什么会这样?我如何修复 .htaccess ,以便 test2.php 返回HTTP/1.1 200 OK

0 个答案:

没有答案