Hi, for specific reasons I won’t go into I want “https://domain.com/ ” to throw a 404 error.
So only https in combination with the bare domain name as I’ve written it there.
E.g. “https://domain.com/page.php ” should work fine.
How would I write this in .htaccess? (I did research it but couldn’t find anything that made this clear to me)
rpkamp
November 22, 2011, 9:02am
2
Does it have to be 404 not found, or would 403 forbidden be okay as well?
rpkamp
November 22, 2011, 2:20pm
4
Apache can’t do that, you should do that from the file that is called.
Or maybe you can redirect the location to some other location that is allowed?
dklynn
November 25, 2011, 6:26am
5
Rémon,
Sorry, mate, you can specify an R=404 when required. Select the file and send it to the 404 handler with an R=404 and that should do it for him.
Regards,
DK
rpkamp
November 25, 2011, 7:01am
6
But where do you send it to? You can’t send it to the requested location, that would be loopy …
In the Apache docs it does say the code has to be in the range 300-400 btw
‘redirect|R [=code]’ (force redirect)
Prefix Substitution with [noparse]http://thishost [/noparse][:thisport]/ (which makes the new URL a URI) to force a external redirection. If no code is given, a HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want to use other response codes in the range 300-400 , simply specify the appropriate number or use one of the following symbolic names: temp (default), permanent, seeother. Use this for rules to canonicalize the URL and return it to the client - to translate /~'' into
/u/‘’, or to always append a slash to /u/user, etc.
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriteflags , bold added by me