Helmet Posted February 25, 2009 Share Posted February 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146922-force-404/ Share on other sites More sharing options...
Helmet Posted February 26, 2009 Author Share Posted February 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/146922-force-404/#findComment-771478 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.