简体   繁体   English

WordPress永久链接,无错误404页

[英]Wordpress permalink with no error 404 page

i am using wordpress permalink like url.com/article-name but i dont want errors 404 handled by my page - so redirected to the normal server error page. 我使用的是诸如url.com/article-name之类的wordpress永久链接,但我不希望页面处理错误404-因此将其重定向到正常的服务器错误页面。 I am using the following .htaccess: 我正在使用以下.htaccess:

# 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

Can someone help me how i have to adjust the .htaccess code that a error is not redirected to the index.php. 有人可以帮助我如何调整错误不会重定向到index.php的.htaccess代码。 If i deleted the .htaccess any links redirects to the server error 404 page. 如果我删除了.htaccess文件,则任何链接都将重定向到服务器错误404页面。

thank you 谢谢

Just add this 只需添加此

ErrorDocument 404 /404.php
# where 404.php is your error page

According to this answer at https://wordpress.stackexchange.com/ you should use 根据https://wordpress.stackexchange.com/上的此答案 ,您应该使用

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(robots\.txt|sitemap\.xml(\.gz)?)
    RewriteCond %{REQUEST_FILENAME} \.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ [NC]
    RewriteRule .* - [L]
</IfModule>

Hope it helps! 希望能帮助到你!

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

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