2012-09-12 46 views
3

我正在幫助一個網站的朋友,我創建了幾個PHP頁面,然後他複製到根目錄。問題是,htaccess文件的設置方式使得我無法訪問我創建的任何新的php文件,但我可以訪問所有的html文件。我看了很多文檔來編輯htaccess,但是我無法使它工作。任何幫助表示讚賞。我已經添加了新的頁面contact.php,顯示-captcha.php和感謝,you.php訪問新的PHP文件

RewriteEngine on 
RewriteRule ^(.*)\.htm$ $1.php [NC] 

#RewriteCond %{REMOTE_ADDR} !71\.239\.5\.36 
#RewriteCond %{REQUEST_URI} !/maintenance.html$ 
#RewriteCond %{REQUEST_URI} !/img(.*)$ 
#RewriteCond %{REQUEST_URI} !/sync/$ 
#RewriteRule $ /maintenance.html [R=302,L] 

##Errors## 
ErrorDocument 400 /error.php 
ErrorDocument 401 /error.php 
ErrorDocument 403 /error.php 
ErrorDocument 404 /error.php 
ErrorDocument 500 /error.php 

##Redirect## 
RewriteCond %{HTTP_HOST} ^www.example.net [NC] 
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301] 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule ^(.*)$ https://example.net/$1 [R,L] 

##Common Files## 
RewriteRule ^(.*)\~\57(.*)$ $1Main.php?file=$2 [NC] 
RewriteRule ^(.*)ajax\57(.*)$ $1Main.php?ajax&$2 [NC] 
RewriteRule ^(.*)sync\57(.*)$ $1Main.php?sync&$2 [NC] 
RewriteRule ^(.*)backup\57(.*)$ $1Main.php?backup&$2 [NC] 
RewriteRule ^(.*)SampleDoc(\57)(.*[^\57])(\57?)$ $1index.php?count=$3 [NC] 

##REDIRECTS## 
RewriteRule ^(.*)menu(\57)(.*[^\57])(\57)(.*[^\57])$ $1menu.php [NC] 
RewriteRule ^(.*)menu(\57)(.*[^\57])(\57?)$ $1menu.php [NC] 
RewriteRule ^(.*)menu(\57?)$ $1menu.php [NC] 

RewriteRule ^(.*)checkout(\57)(.*[^\57])(\57)(.*[^\57])$ $1checkout.php [NC] 
RewriteRule ^(.*)checkout(\57)(.*[^\57])(\57?)$ $1checkout.php [NC] 
RewriteRule ^(.*)checkout(\57?)$ $1checkout.php [NC] 

RewriteRule ^(.*)ThankYou(\57)(.*[^\57])(\57?)$ $1ThankYou.php?$3 [NC] 
RewriteRule ^(.*)ThankYou(\57?)$ $1ThankYou.php [NC] 

RewriteRule ^(.*)Contact(\57)(.*[^\57])(\57?)$ $1contact.php?$3 [NC] 
RewriteRule ^(.*)Contact(\57?)$ $1contact.php [NC] 

RewriteRule ^(.*)account(\57)(.*[^\57])(\57)(.*[^\57])(\57)(.*[^\57])$ $1account.php?type=$3&email=$5&code=$7 [NC] 
RewriteRule ^(.*)account(\57)(.*[^\57])(\57?)$ $1account.php?type=$3 [NC] 
RewriteRule ^(.*)account(\57?)$ $1account.php [NC] 

RewriteRule ^(.*)catering(\57)(.*[^\57])(\57)(.*[^\57])$ $1catering.php?$3$5 [NC] 
RewriteRule ^(.*)catering(\57)(.*[^\57])(\57?)$ $1catering.php?$3 [NC] 
RewriteRule ^(.*)catering(\57?)$ $1catering.php [NC] 

RewriteRule ^(.*)changepassword\57(.*[^\57])\57(.*[^\57])$ $1account.php?type=changepssd&email=$2&code=$3 [NC] 
RewriteRule ^(.*)join(\57)(.*[^\57])(\57)(.*[^\57])$ $1account.php?type=join&email=$5&code=$7 [NC] 

我試圖添加contact.php但你可以看到它沒有幫助。

+0

你如何試圖訪問新的PHP文件?什麼是您使用的URL? –

+0

www.sample.net/contact.php並且該頁面包含文件require_once(「./include/fgcontactform.php」); require_once(「./ include/captcha-creator.php」); require_once 我有www.sample.net/menu.php使用上述文件 – Vinit

+0

我在瀏覽器中檢查了檢查器,它所說的全部是500錯誤 – Vinit

回答

1

如果您不打算將路徑變量移動到查詢字符串,則根本不需要重寫規則。只需刪除聯繫人頁面的RewriteRules即可。如果你仍然得到找不到網頁,刪除

ErrorDocument 500 /error.php 

所有的錯誤,從頁面沒有找到服務器錯誤都得到相同的error.php。你的contact.php中可能有一些錯誤,這就是爲什麼你總是得到這個頁面。

希望有幫助!

+0

我會給你一個鏡頭..因爲只有一個小時留在賞金,我會獎勵給你......但我會回到你再次測試後..謝謝 – Vinit

-1

嘗試接觸

#RewriteRule ^(.*)Contact(\57)(.*[^\57])(\57?)$ $1contact.php?$3 [NC] 
#RewriteRule ^(.*)Contact(\57?)$ $1contact.php [NC] 

刪除現有的線路,並添加這些:

RewriteRule ^(.*)contact(\57)(.*[^\57])(\57)(.*[^\57])$ $1contact.php [NC] 
RewriteRule ^(.*)contact(\57)(.*[^\57])(\57?)$ $1contact.php [NC] 
RewriteRule ^(.*)contact(\57?)$ $1contact.php [NC] 

並注意區分大小寫。

+0

試過這個,但沒有奏效。 – Vinit

+1

有關信息「[NC]」是「沒有區分大小寫」 –