php 从 XAMPP 移动后,WAMP .htaccess 出现内部服务器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8769799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WAMP .htaccess gives Internal Server Error after moving from XAMPP
提问by user1123379
Not long ago, I moved from xampp to wamp
And now when I entered my website this error has appeared:
不久前,我从 xampp 转移到 wamp
现在当我进入我的网站时,出现了这个错误:
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
Internal Server Error 服务器遇到内部错误或配置错误,无法完成您的请求。请联系服务器管理员 admin@localhost 并告知他们发生错误的时间,以及您可能执行的任何可能导致错误的操作。服务器错误日志中可能提供有关此错误的更多信息。
When I used this code in .htaccess:
当我在 .htaccess 中使用此代码时:
<FilesMatch "\.(pdf|swf|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(html|cgi|php|htm)$">
Header set Expires "Thu, 01 Dec 2003 16:00:00 GMT"
Header set Cache-Control "no-store, no-cache, must-revalidate"
Header set Pragma "no-cache"
</FilesMatch>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
<Files *.js>
SetOutputFilter DEFLATE
</Files>
<Files *.css>
SetOutputFilter DEFLATE
</Files>
How can I fix this problem?
我该如何解决这个问题?
I found apache_error.log:
我找到了 apache_error.log:
[Sat Jan 07 13:58:06 2012] [alert] [client 127.0.0.1] C:/wamp/www/website/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer: localhost
[Sat Jan 07 13:58:06 2012] [alert] [client 127.0.0.1] C:/wamp/www/website/.htaccess:无效的命令“Header”,可能拼写错误或由服务器中未包含的模块定义配置,引用者:本地主机
回答by
In wamp server click on apache ,apache modules and click(mark) on the rewrite_module and restart wamp server your problem is solved
在 wamp 服务器中单击 apache ,apache 模块并在 rewrite_module 上单击(标记)并重新启动 wamp 服务器,您的问题就解决了
回答by Rob Forrest
As XP1 said, the answer to this is to enable headers_module in WAMP.
正如 XP1 所说,答案是在 WAMP 中启用 headers_module。
Either use the WAMP interface or add this to your httpd.conf
使用 WAMP 接口或将其添加到您的 httpd.conf
LoadModule headers_module modules/mod_headers.so
回答by JBS
If enabling mod_headersdidn't fix your problem, then it is being caused by AddOutputFilterByType
如果启用mod_headers没有解决您的问题,那么它是由AddOutputFilterByType引起的
This can be fixed by enabling another module, mod_filter.
这可以通过启用另一个模块mod_filter 来解决。
Probably also a good idea to add the 'ifModule' code if your server settings ever get reset or you migrate your project to a different server. This worked for me:
如果您的服务器设置被重置或者您将项目迁移到不同的服务器,那么添加“ifModule”代码可能也是一个好主意。这对我有用:
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
回答by Shiva Avula
After a lot of searching in WAMP, the headers module did not enable mod_headers module. You can enable the mod_headers in httpd.conf file. At start a list of modules are shown just find mod_header and remove the # at start of it and restart WAMP. Now the mod_headers module will be enabled and loaded.
在 WAMP 中搜索了很多,headers 模块没有启用 mod_headers 模块。您可以在 httpd.conf 文件中启用 mod_headers。在开始时显示模块列表,只需找到 mod_header 并删除它开头的 # 并重新启动 WAMP。现在将启用并加载 mod_headers 模块。
回答by Ahmed Deeb
Go To Wampmanger LeftClick , Apache Then ApacheModules and check (rewrite_module) , Restart Apache ,then it will be ok
转到 Wampmanger LeftClick , Apache 然后 ApacheModules 并检查 (rewrite_module) , 重新启动 Apache ,然后就可以了
回答by Ankit Anand
Add this and the code should work fine
添加这个,代码应该可以正常工作
<IfModule mod_expires.c>
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
</IfModule>
回答by Nimrod Mpandari
sometimes the space between location and url is the solution for example:
有时 location 和 url 之间的空间是解决方案,例如:
header('Location:usertimeline.php');
gives no error as opposed to
没有错误,而不是
header('Location: usertimeline.php');
I am a beginner on WAMP because my header module and all the stuff were ticked but in just doing this It was over.
我是 WAMP 的初学者,因为我的头模块和所有东西都被勾选了,但仅仅这样做就结束了。
回答by SwR
I think to execute the commands in .htaccess files the rewrite module of the apache should be enabled but it is disabled by default.
我认为要执行 .htaccess 文件中的命令,应该启用 apache 的重写模块,但默认情况下它是禁用的。
If you are using WAMP then just click on the wamp server icon in the taskbar -> Apache -> Apache Modules. This will show you the list of modules.Then scroll down to find rewrite_module and click on it. When u click on it WAMP gets restarted with rewrite_module enabled.
如果您使用的是 WAMP,那么只需单击任务栏中的 wamp 服务器图标 -> Apache -> Apache 模块。这将显示模块列表。然后向下滚动以找到 rewrite_module 并单击它。当你点击它时,WAMP 会在启用 rewrite_module 的情况下重新启动。
So I think if you activate this module then it might solve your problem.
所以我认为如果你激活这个模块,那么它可能会解决你的问题。