2013-02-22 123 views
0

这里是我的index.php文件:PHP获取路径信息

<?php 

echo $_SERVER['PATH_INFO']; 

?> 

这里是我的htaccess文件:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /something 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 

如果我输入的东西/ index.php文件/打招呼,结果应该是/你好
但是,如果我是/你好,它说
未定义的索引:PATH_INFO在/Library/WebServer/Documents/xcart/index.php在线3
我怎样才能得到相同的结果?

+0

那么这种行为正是该服务器的VAR是专为。我建议你试着解释你最近想做什么以及为什么。也许那么我们明白你的问题。 – arkascha 2013-02-22 06:09:11

回答

0

尝试:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^/(.*)/?$ something/$1 
</IfModule>