[英]Redirect to custom 404 page using .htaccess and country location (in website url)
[英]How to redirect url to 404 page using htaccess?
當我點擊https://mobilecoderz.com/contactffdd時,它將返回404錯誤頁面。
絕對正常。
當我點擊https://mobilecoderz.com/contact時,它將返回“聯系”頁面。
絕對正常。
但是,當我點擊https://mobilecoderz.com/contact/adfadf時,它也會返回聯系頁面。
但是它應該返回404錯誤頁面。 我如何使用htaccess做到這一點?
您可以在.htaccess的頂部使用以下兩行:
DirectoryIndex index.html
ErrorDocument 404 http://yoururl
DirectoryIndex將默認使yoururl加載yoururl / index.html,在ErrorDocument中使用http://將使其重定向到新URL。
要么
RedirectMatch 404 ^/abc/.*$
要么
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/404.php [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.