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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.