I have a website running on an apache server. I have created a new page (mantenimiento.php) to automatically redirect users there while I deploy to the production environment.
I have added the following code to the .htaccess:
RewriteEngine on
#RewriteCond %{REQUEST_URI} !/mantenimiento.php$
#RewriteCond %{REMOTE_ADDR} !^x.xxx.xxx.xxx //my public ip
#RewriteRule $ /mantenimiento.php [R=302,L]
(I am new to using rewrite rules)
I have specified my ip so that I can work with the page. The rest of the users should see the page mantenimiento.php
However, when accessing the website with an anonymous browser like Tor, I see the error:
The stylesheet <my-site-web> was not loaded because its MIME type, "text/html", is not "text/css".
Styles and images are not uploaded.
I think the appended part in .htaccess causes this to fail. If I comment the lines of the .htaccess the styles are loaded correctly.
How can I make the styles and images load?
Thanks in advance
You need to exclude js/css/images
from the new rule:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/mantenimiento\.php$ [NC]
RewriteCond %{REMOTE_ADDR} !^x.xxx.xxx.xxx
RewriteRule !\.(css|js|png|jpe?g|gif|ico)$ /mantenimiento.php [R=302,L,NC]
Otherwise web browser will try to render output from /mantenimiento.php
as css or image resource.