我有一個.htacess文件,如;
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
讓我說我有一個網址:www.example.com/index/action
。 當我的index.php打印$_SERVER['PATH_INFO']
我看到/action
但如果我的網址就像是www.example.com/index1/action
,我可以看到/index1/action
,但我想看看在這兩個案例的完整路徑。我該如何解決它?
我有一個.htacess文件,如;
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
讓我說我有一個網址:www.example.com/index/action
。 當我的index.php打印$_SERVER['PATH_INFO']
我看到/action
但如果我的網址就像是www.example.com/index1/action
,我可以看到/index1/action
,但我想看看在這兩個案例的完整路徑。我該如何解決它?
如果你想看到它的URL重寫之前,我相信你正在尋找:
$_SERVER['REQUEST_URI']
你可能會尋找$_SERVER['PHP_SELF']
。
對於www.example.com/index/action
,你會得到/index.php/index/action
爲www.example.com/index1/action
,你會得到/index.php/index1/action
嘗試$_SERVER['REQUEST_URI']
的代碼這是很有幫助的位將插入頁面的地址,用戶當前因此,如果您使用「http://test.com/pages/test/」,代碼將複製「/ pages/test /」。要在代碼中使用它: