I am using the Laravel platform for my website. What I want to achieve is to show only one web page with some info about the website. All other pages are still in development mode, so i want them to protect with .htaccess.
Here is my .htaccess file, unfortunately it is asking for password for every single page:
AuthName "myweb"
AuthUserFile "/home/passwd"
AuthType Basic
require valid-user
<Files "*">
Require valid-user
</Files>
<Files "start.html">
Allow from all
Satisfy Any
</Files>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
If there is some solution with .htaccess it will be great, but if Laravel offers an easy solution (except the maintenance mode) I can except that too.
Thanks in advice !
Try this in the top of your routes.php (or web.php depending on version)
if (getenv('REMOTE_ADDR') != '192.168.6.3' && !\Request::is('/')) {
abort(404);
}
It says if the Request is not the home screen and the IP address is not my IP address, abort with a 404.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.