Quantcast
Channel: BulletProof Security Forum » All Posts
Viewing all articles
Browse latest Browse all 12489

410 htaccess redirect – redirect html files, redirect query strings, redirect Posts or Categories

$
0
0

A 410 Gone htaccess redirect can be used when a link/URL/URI has been permanently removed or deleted.  The primary difference between a 410 and 404 HTTP Status Code is that 410 Gone means the link/URL/URI intentionally no longer exists and 404 Not Found means that the link/URL/URI either unintentionally or intentionally no longer exists.  If a link/URL/URI has been moved to another URI then a 301 redirect should be used instead of a 410 redirect.

Redirect a Post to the BPS 410.php template file.

RewriteRule ^example-post-name-1/$ - [G,NC]
RewriteRule ^example-post-name-2/$ - [G,NC]

Redirect a Category and all Posts under that Category to the BPS 410.php template file.

RewriteRule ^example-category-name/.* - [G,NC]

Redirect all Requests based on a Query String: ?example-query-string to the BPS 410.php template file.

RewriteCond %{QUERY_STRING} example-query-string
RewriteRule .* - [G,NC]

Redirect all .html files except for example-filename-1.html and example-filename-2.html to the BPS 410.php template file.

RewriteRule ^example-filename-1\.html$ - [L]
RewriteRule ^example-filename-2\.html$ - [L]
RewriteCond %{REQUEST_URI} ^(.*)\.html [NC]
RewriteRule ^(.*)$ - [G,NC]

Redirect a specific .html file to the BPS 410.php template file.

RewriteRule ^example-html-filename-1\.html$ - [G,NC]

General Info, Notes, Setup & Usage:
As of BPS Pro 10.4 and BPS .52 a new 410.php template file has been created and a new htaccess ErrorDocument directive has been added to the root htaccess file:  ErrorDocument 410 /wp-content/plugins/bulletproof-security/410.php
410 Gone Requests will be logged in the BPS Security Log.  To create 410 Gone Redirect htaccess code in BPS Custom Code use the Custom Code setup steps below.

1.  Go to the BPS htaccess File Editor page, click on the Your Current Root htaccess File tab, scroll down in your Root .htaccess file code until you see this .htaccess code below (or similar code – may look slightly different than the code below).

# WP REWRITE LOOP START
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

2.  Copy your # WP REWRITE LOOP START code to this BPS Root Custom Code text box:  CUSTOM CODE WP REWRITE LOOP START
3.  After you have copied your WP Rewrite Loop Start .htaccess code to the Custom Code text box add your particular custom 410 htaccess redirect code.  Your code should look something like the example below.
4.  Click the Save Root Custom Code button.
5.  Go to the BPS Security Modes page, click the Create secure.htaccess File AutoMagic button and activate Root folder BulletProof Mode.

Example:

# WP REWRITE LOOP START
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^example-post-name-1/$ - [G,NC]
RewriteRule ^example-post-name-2/$ - [G,NC]
RewriteRule ^example-category-name/.* - [G,NC]
RewriteRule ^example-html-filename-1\.html$ - [G,NC]
  • This topic was modified 6 hours, 12 minutes ago by  AITpro Admin.
  • This topic was modified 6 hours, 11 minutes ago by  AITpro Admin.

Viewing all articles
Browse latest Browse all 12489

Trending Articles