Skip to main content

Web Servers & Tools

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 

 

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.

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

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}