这是我的index.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/hello,结果将是/hello
但是如果我有什么/你好,上面写着
未定义的索引:第3行/library/webserver/documents/xcart/index.php中的路径信息
我怎样才能得到同样的结果?

最佳答案

尝试:

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

关于php - php获取htaccess的路径信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15017896/

10-13 00:30
查看更多