2012-09-12 48 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]”是“没有区分大小写” –