Web Servers & Tools
Prevent Search Engines from crawling the url with queries and try it
RewriteEngine On
RewriteBase /
# Target search engine bots
RewriteCond %{HTTP_USER_AGENT} (Googlebot|Google-InspectionTool|bingbot|Slurp|DuckDuckBot|Yandex|Baiduspider) [NC]
# Rule 1: Return 410 for any URL with a query string (for search engines only)
RewriteCond %{QUERY_STRING} .+
RewriteRule ^ - [G]
if you want to exclude the sitemap.xml from this then do it like this
Setup Basic Auth on httaccess with whitlisting specifc IP
Setup Basic Auth on httaccess with whitlisting specifc IP
AuthType Basic
AuthName "Name of Member’s Area"
AuthUserFile /home//private_html/.htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 10.10.10.10
Allow from 20.20.20.20
Satisfy any
ErrorDocument 401 /error_pages/401.html
AddHandler server-parsed .ht
Configuring Next.js app for redirection while whitelisting specific IPs.
Configuring Next.js app for redirection while whitelisting specific IPs.
Below is the code that enables the execution of a Next.js application for specific IP addresses while redirecting other users to the primary website.
#RewriteEngine On
## WH
RewriteCond %{REMOTE_ADDR} !10\.10\.10\.10$
RewriteCond %{REMOTE_ADDR} !11\.11\.11\.11$
RewriteRule ^(.*)$ https://www.live-website.com/$1 [L,R=301]
Title: Redirecting All Users to HTTPS, Except for Specific IPs Using .htaccess
Introduction:
In web development, sometimes you may want to redirect all users accessing your website to a specific URL, such as www.example.com. However, there might be certain cases where you need to exclude specific IP addresses from this redirection. In this article, we will explore how to achieve this using the .htaccess file.
Cors Origin nginx code
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST';
NextJs htaccess setting
The content of the .htaccess for nextjs application is
# Redirect traffic to your port 3001
DirectoryIndex
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)?$ http://127.0.0.1:3001/$1 [P,L]
to exclude a file from this rule (EX: test.txt) we can add this like
RewriteCond %{REQUEST_URI} !test\.txt [NC]
Full Code
Error Initilize GIT git init --initial-branch=main
Error Initilize GIT git init --initial-branch=main
> git init --initial-branch=main
error: unknown option `initial-branch=main'
regular code
cd existing_folder
git init --initial-branch=main
git remote add origin [email protected]:path/to/project.git
git add .
git commit -m "Initial commit"
git push -u origin main
to fix the problem you can use this way
Add artifact repository type into composer
Add artifact repository type into composer
to add an offline package and use it you can do the following
{root}/vendor/{vendor}/packages
# composer config repositories.{your-name} artifact $(pwd)/vendor/{vendor}/packages # composer require {your-package}
Clear a redis cache in Docker
docker exec -it {container-name} redis-cli FLUSHALL
How to Install Nginx on CentOS 8 and Configure Nginx with Multiple PHP Versions
In this guide, we’ll discuss how to install Nginx on a CentOS 8 server and how to run Multiple PHP Versions on one server using nginx and PHP-FPM on CentOS 8
After installing CentOS 8 you will have the root user an you might have {another user} that you created during the installation, anyway and in both cases we will not use any user from those users an we will start create our own {web user}