2015-11-12 48 views
0
  • 我有一個目錄讓我們CALLIT dir1我有它,它被稱爲index.html一個HTML文件和我在同一個目錄.htaccess文件,它會將所有的URL index.html
  • 我也有dir1 dirctory clled dir2它有php文件index.php
  • index.html將請求發送到index.php使用Ajax請求正常工作時的URL是localhost/dir1/或與還與因.htaccess文件localhost/dir1/index.htmllocalhost/dir1/anything_here當網址localhost/dir1/anything/它不因爲它應該工作,或者還可以當網址是localhost/dir1/anything/anything/any../..

這個問題的解決方法是什麼?AJAX和PHP目錄

+0

你也應該張貼.htaccess文件的內容。如果我們看不到它,我們無法知道.htaccess文件是正確還是錯誤。 – Dragos

回答

0

解決方案是使用絕對URL而不是相對的URL。所以,基本上,這些請求應做/path/to/the/php/file.php,而不是path/to/...

+0

你的意思是我使用系統目錄 – user3625569

+0

不,我的意思是你必須改變你的ajax選項來發送請求到'/ dir1/dir2/index.php' –

+0

你也必須確保你不要重寫這個路徑.. –

0

,你可以只使用base標籤中head部分:

<head> 
    <base href="http://url.com/dir1/"> 
</head> 
+0

沒有工作? – user3625569