I'm trying to develop, test, and debug a website's CSS, and PHP code, and block the public from seeing any of the websites pages (by redirecting them to a parked "maintenance" page), while the site is still being developed. This site is NOT a WordPress site, so the problem is NOT solvable by simply applying a plugin. However it may be solvable by using .htaccess
, if it's configured correctly.
I'm using the following code in the.htaccess
file in the root of my websites tree:
<IfModule mod_rewrite.c>
# Allow the developer(s) (set to example.com's IP address for demonstration purposes) access to the website, via their IP address. #
RewriteCond %{REMOTE_ADDR} !^(93\.184\.216\.34)
# Allow users access to the directory containing the pages that handle HTTP error codes. #
RewriteCond %{REQUEST_URI} !^.*\/(error_documents)\/.+$ [NC]
# Allow users access to the parked "maintenance" page (duh!). #
RewriteCond %{REQUEST_URI} !^.*\/park\/index\.php$ [NC]
# During development and maintenance periods, redirect all others to the parked "maintenance" page. #
RewriteRule .* /park/index.php [R=302,L]
</IfModule>
Now, this works perfectly fine for it's intended purpose, but now I have (2) new problems:
It also blocks the Google Structured Data Testing Tool, which I need to give access to for testing the websites "Structured Data".
It also blocks the W3C Markup Validation Service, which I need to give access to, to check the markup's validity.
In order to solve these (2) problems, the following has to be accomplished:
- Figure out the
HTTP_USER_AGENT
string the aforementioned (2) services are using, to access the website, and specifically allow those user agents (i.e. In consistency with the.htaccess
code block, above, check that the request is NOT coming from those (2) services. If it is, then be sure NOT to redirect them to the parked "maintenance" page).
To give you an initial starting-point clue, that directive might look a little something like this:
RewriteCond %{HTTP_USER_AGENT} !^GoogSDTT
RewriteCond %{HTTP_USER_AGENT} !^W3CValidator