apache - How to rewrite a directory to a 404 page? -


i have hosting account, has website on it. let's call it: www.example.com
in cpanel, i've set addon domain: www.example2.com, points folder on www.example.com:
www.example.com/example2

how can throw 404 error if directly visits www.example.com/example2 ?

i've tried in .htaccess file:

options -indexes rewriteengine on options +followsymlinks rewriterule ^example2(.*) - [r=404,l,nc] 

but didn't work. still shows index.php of example2 folder. both www.example.com , www.example2.com websites have own .htaccess file. if disable .htaccess file on www.example2.com, above mentioned redirect works.

inside /example2/.htaccess have rule first rule:

rewriteengine on  # if host name not example2 throw 404 rewritecond %{http_host} !^(www\.)?example2\.com$ [nc] rewriterule ^ - [l,r=404] 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -