Reputation: 28853
I'm trying to make it so that all sub-domains go to a 404 page, except for Admin:
# MAKE ALL OTHER SUB DOMAINS 404
RewriteCond %{HTTP_HOST} ^\.example\.com$
RewriteRule !^404/? [R=404,L]
# ALLOW ADMIN SUB DOMAIN AND SEND TRAFFIC TO SUB FOLDER
RewriteCond %{HTTP_HOST} ^admin\.example\.com$
RewriteRule !^admin/? admin%{REQUEST_URI} [NC,L]
But the 404 doesn't work (it shows root content)... What have I done wrong?
It should be setting a status of 404 but loading the content from the 404 directory at the root level via the rewrite.
Upvotes: 0
Views: 930
Reputation: 786339
Have it this way:
RewriteEngine On
RewriteBase /
# ALLOW ADMIN SUB DOMAIN AND SEND TRAFFIC TO SUB FOLDER
RewriteCond %{HTTP_HOST} ^admin\.example\.com$ [NC]
RewriteRule !^admin/? admin%{REQUEST_URI} [NC,L]
# MAKE ALL OTHER SUB DOMAINS 404
RewriteCond %{HTTP_HOST} !^(www|admin)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule !^404/ 404/ [L]
Upvotes: 1