Jump to content

Force 404?


Helmet

Recommended Posts

Hi,

 

Is it possible to force a 404 using htaccess and mod_rewrite similar to how redirects are done? I would like to avoid having to create php files to do the redirect in some addon domain directories that I want to make sure are not linked to the main domain, so addondomain_com.example.com should show a 404, whereas hitting addondomain.com directly should not. I haven't had any luck finding an example of this, so I'm thinking it can't be done. Is this true?

 

H

Link to comment
https://forums.phpfreaks.com/topic/146922-force-404/
Share on other sites

Apparently this is the way to do it. Rewrite to a file that doesn't exist, which serves the 404 headers:

 

RewriteCond %{HTTP_HOST} ^(.*)\.example.com$
RewriteRule ^(.*)$ idonotexist.html [L]

 

The only problem is that my host's default 404 page shows that the url "idonotexist.html" was not found. It looks like this solution will also necessitate a custom 404.

Link to comment
https://forums.phpfreaks.com/topic/146922-force-404/#findComment-771478
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.