Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache ErrorDocument在其上工作';s own,添加任何其他内容都会导致500-.htaccess_Apache_.htaccess - Fatal编程技术网

Apache ErrorDocument在其上工作';s own,添加任何其他内容都会导致500-.htaccess

Apache ErrorDocument在其上工作';s own,添加任何其他内容都会导致500-.htaccess,apache,.htaccess,Apache,.htaccess,我需要一些关于.htaccess文件的帮助 我想处理一些可能性,将非www转换为www,重定向一些文件,设置缓存,等等 ErrorDocument 404/404.php本身工作正常,但每当我尝试添加任何其他部分时,都会导致“500内部服务器错误” 所有部件的示例: //Rewrite to www Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^mydomain.com[nc] RewriteRule ^(.

我需要一些关于.htaccess文件的帮助

我想处理一些可能性,将非www转换为www,重定向一些文件,设置缓存,等等

ErrorDocument 404/404.php本身工作正常,但每当我尝试添加任何其他部分时,都会导致“500内部服务器错误”

所有部件的示例:

//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com[nc]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

//301 Redirect Old File
Redirect 301 /index.html /

//Caching schema
<FilesMatch "\.(.css)$">
Header set Cache-Control "public, max-age=86400"
</FilesMatch>

//Custom 404 errors
ErrorDocument 404 /404.php

等等。

除非我变得老态龙钟(可能),否则我认为您不能使用//在Apache配置中添加注释。用#作为你评论的起始行。对。。。没有这些台词仍然无法工作,尽管没有错误向我扑来。服务器的AllowOverride指令是否允许您使用这些指令?不确定如果你试图做一些被禁止的事情,那会不会抛出500英镑APache错误日志可能会提供比500错误更详细的信息。在我的两个示例编辑中刚刚实现,我得到的是重定向循环,而不是500如果你得到的是重定向循环,你是否确保index.html不是APache默认文件(DirectoryIndex指令)?如果是这样的话,当/index.html被重定向到/(重定向到/index.html等)时,您将得到一个重定向循环,。
Redirect 301 /index.html /
ErrorDocument 404 /404.php

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com.com[nc]
RewriteRule ^(.*)$ http://www.mydomain.com.com/$1 [r=301,nc]
Redirect 301 /index.html http://www.mydomain.com.com
ErrorDocument 404 /404.php