Richy
Richy

Reputation: 167

HTACCESS maintenance mode rewrite

There are plenty of HTACCESS maintenance mode redirects here on stack overflow but I have yet to find one which will work for my structure.

I would like to redirect www.example.com to www.example.com/sub/maintenancemode.html. However I would still like to have access to subdomain.example.com. Subdomain will be used for dev and staging purposes etc

Upvotes: 0

Views: 256

Answers (2)

Richy
Richy

Reputation: 167

Ended up using this in the end

RewriteEngine On
RewriteBase /

RewriteRule ^(dev|staging)($|/) - [L]
RewriteCond %{REQUEST_URI} !/maintenance/coming-soon.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance/coming-soon.html [R=302,L]

Upvotes: 0

Florian Lemaitre
Florian Lemaitre

Reputation: 5748

Here is your .htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^subdomain\.example\.com$
RewriteRule ^.* /sub/maintenancemode.html?

Upvotes: 1

Related Questions