繁体   English   中英

为什么.htaccess向我显示“内部服务器错误”?

[英]why .htaccess is showing me “Internal Server Error”?

在我的网站上,我使用.htaccess规则从网址中删除了.php扩展名。 这样我可以转到没有.php扩展名的任何页面。 例如:

http://localhost/aponit/dev/zones (there are no .php extension)

现在,我在php页面中有一个链接来更新表单数据。 链接如下:

<a class="btn btn-success btn-xs" href="<?php echo SITE_URL."update/$zone_id"?>" >Edit</a>

此链接显示以下网址:

http://localhost/aponit/dev/update/54

但不幸的是,它向我显示错误消息:

内部服务器错误

我正在使用以下.htaccess规则:

ErrorDocument 404 /not-found.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^update/([0-9]+) update?z=$1 [L]

尝试去:

ErrorDocument 404 /not-found.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

并发布详细日志文件???

如果站点不在根域下运行,则yuo提供的.htaccess代码将无法正常运行。 例如

RewriteRule ^update/([0-9]+) update?z=$1 [L]

此代码块告诉服务器,任何以数字开头的以“ update”开头的URI都将被重写。 但是在您的情况下,URI始终以“ aponit / dev /”开头。 因此此代码将无法正常工作。

设置虚拟主机。 您将在线获得许多可用的教程,该教程如何基于服务器软件(XAMPP / WAMP等)来设置虚拟主机。

如果您只想从网址中删除.php,请在.htaccess中使用以下代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM