2017-04-13 54 views
0

我有一個PHP文件,該文件是home.php的.htaccess錯誤:請求的URL沒有此服務器

上找到

我在本地主機上的網址是

http://localhost:8888/photo/home.php

我想從刪除.php網址

,所以我創建.htaccess文件

RewriteEngine On 

RewriteRule ^home?$ home.php 

但我不斷收到此錯誤

請求的URL /照片/家在此服務器上找到。

+0

了''^手段開始在字符串的開始搜索。你可能想'^ /?照片/家' – Cfreak

+0

你好@Cfreak。謝謝你的回覆,但是這也不管用'RewriteRule^/?photo/home home.php' –

+0

你可能需要使用這個:'RewriteRule ^(/?photo)/ home $ 1/home.php'。 '/ photo'需要在重寫的URL中。反向引用的原因是,根據這個RewriteRule的位置,在匹配的URL的開頭可能有也可能不是斜槓。 – Jost

回答

1

像這樣嘗試,在你的照片目錄中。

RewriteEngine On 

# neither a file nor a directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^home$ home.php [QSA,L] 
0

首先,確保您的.htaccess文件位於項目的基礎目錄中。接下來,按照these htaccess rules設置您的重定向。

你可能會尋找對的.htaccess的解決方案是:

RewriteEngine On 

#Neither a file nor a directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^photo/home$ photo/home.php [QSA,L] 
相關問題