我遇到了一个问题,固定链接.htaccess代码会阻止自定义错误处理。当我删除WordPress代码时,错误处理可以正常工作。
下面是我的代码:
php_value memory_limit 96M
php_value upload_max_filesize 250M
php_value post_max_size 250M
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
ErrorDocument 400 /error.php
AddType application/msword doc
AddType application/vnd.ms-excel xls
AddType application/powerpoint ppt
AddType application/vnd.ms-word.document.macroEnabled.12 .docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx有没有一种方法可以保持WordPress代码的完整性,同时仍然有一个针对400个错误的自定义错误文档?
提前谢谢你,
斯科蒂
发布于 2012-02-07 03:55:21
Wordpress使用引导index.php文件工作。wordpress目录中的所有请求都由它处理。因此,自定义错误文档不能通过apache工作,您需要在您正在使用的Wordpress主题中为它们创建模板页面。
发布于 2014-05-23 02:23:44
如果您想在WordPress中使用带有当前主题的自定义错误页面,则需要执行以下操作...
在当前的
400.php模板页面。请确保包含正常的get_header()和get_footer()代码。理想情况下,您的主题已经有一个functions.php文件,所以只需复制它,重命名它,然后更改其中的内容/消息。
(您可以将此代码放在最后一行或其他任何位置)
/**
* 400 Error Code Reponse Header
* Note: This allows you to specify 400 RewriteRules in the .htaccess to use a custom 400.php WordPress template.
* Source: http://otroblogmas.com/retornar-410-wordpress/
*
* @param string $template
* @return string
*/
function e12_response_400( $template ) {
if( '400' == $_SERVER['REDIRECT_STATUS'] ) {
status_header( 400 );
if( file_exists( STYLESHEETPATH . '/400.php' ) ) {
return STYLESHEETPATH . '/400.php';
}
}
return $template;
}
add_filter( 'template_include', 'e12_response_400' );https://stackoverflow.com/questions/9166299
复制相似问题