Home › Forums › BulletProof Security Pro › 410 htaccess redirect – redirect html files, redirect query strings, redirect Posts or Categories
Tagged: 410 error, 410 htaccess redirect, 410 redirect
- This topic has 14 replies, 6 voices, and was last updated 3 months, 4 weeks ago by MonicaSwift.
-
AuthorPosts
-
AITpro AdminKeymaster
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 and click the Root Folder BulletProof Mode Activate button.Examples:
# 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]
Redirect Query Strings and URI’s|URL’s:
Example Query Strings:example.com/page/30/?attachment_id=ceprgnhzjqpwfybp/ example.com/^1572/67701.html?*session*id*key*=*session*id*val/
# 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] RewriteCond %{QUERY_STRING} attachment_id=ceprgnhzjqpwfybp RewriteCond %{QUERY_STRING} session(.*)id(.*)key(.*)=(.*)session(.*)id(.*)val RewriteRule .* - [G,NC]
JoseParticipantSorry, I added these two lines and I see a 500 internal error. What can I do? This extension is not working so I’d have to use ftp. /wp-content/plugins/bulletproof-security/admin/xternal/xternal.php. Is it possible deleting these two lines from Filezilla?
RewriteRule ^page/30/?attachment_id=ceprgnhzjqpwfybp/$ - [G,NC] RewriteRule ^1572/67701.html?*session*id*key*=*session*id*val/$ - [G,NC]
AITpro AdminKeymasterThe htaccess code does not look valid to me. Post the links/URL’s that you want to redirect with 410.
http://forum.ait-pro.com/forums/topic/read-me-first-pro/#bps-pro-general-troubleshooting
JoseParticipantThey are two very old url’s (not in wordpress) about 8 years ago that I saw at Google Analytics.
www.mysite.com/page/30/?attachment_id=ceprgnhzjqpwfybp/ and www.mysite.com/^1572/67701.html?*session*id*key*=*session*id*val/
Now the problem is that when I delete the two .htaccess folders, I can log into the site, but when I try to click on bulletproof 500 error reappears because the two folders have been recreated again. What about deleting the two lines I added via Notepad++? I see that the root .htaccess file now is in quarantine.
AITpro AdminKeymasterYou need to manually stop AutoRestore from restoring your root htaccess file if you are unable to use the Xternal Tools Form. Go to this folder: /wp-content/bps-backup/autorestore/root-files/ and delete this file: auto_.htaccess. Then delete your root htaccess file. If your server type needs to have an htaccess file in order for you to login to your website then download this file: /bulletproof-security/admin/htaccess/default.htaccess and upload it to your website root folder and rename it to .htaccess.
Since both of the 410 rules you need to create for these can be Query String conditions then this is the code you need:
RewriteCond %{QUERY_STRING} attachment_id=ceprgnhzjqpwfybp RewriteCond %{QUERY_STRING} session(.*)id(.*)key(.*)=(.*)session(.*)id(.*)val RewriteRule .* - [G,NC]
JoseParticipantOk, done. It’s working now, but there are seven quarantined files that remain quarantined and I can delet them or restore them.
auto_.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/.htaccess 2015-08-08 18:23:55 wpadmin.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/wp-admin/.htaccess 2015-08-08 18:23:55 auto_.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/.htaccess 2015-08-08 18:26:03 wpadmin.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/wp-admin/.htaccess 2015-08-08 18:26:03 auto_.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/.htaccess 2015-08-08 18:35:26 wpadmin.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/wp-admin/.htaccess 2015-08-08 18:43:28 wpadmin.htaccess /homepages/38/dxxxxxxxxx/htdocs/wordpress/wp-admin/.htaccess 2015-08-08 18:46:40
AITpro AdminKeymasterDelete them.
JoseParticipantAnd this code can be placed in the same place?
AITpro AdminKeymasterSee the first post in this forum topic for how and where to add 410 Gone htaccess code.
JoseParticipantOk, thanks a lot again.
AITpro AdminKeymasterI added another example in the first post in this forum topic that shows redirecting/rewriting both Query Strings and URI’s|URL’s together/combined.
brianmaneeParticipantA 301 redirect is a permanent redirect from one URL to another. 301 redirects send site visitors and search engines to a different URL than the one they originally typed into their browser or selected from a search engine results page. These redirects also link various URLs under one umbrella so search engines rank all of the addresses based on the domain authority from inbound links. More about….Redirect a Web Page
Brian
lauryfrieseParticipantTo implement a 410 HTTP status code redirect using an .htaccess file, you can use the Apache mod_rewrite module. Here’s how you can redirect various scenarios using .htaccess:
1. Redirect HTML Files: Drift Boss
`apache
RewriteEngine On
RewriteRule ^(.+)\.html$ – [R=410,L]
`
This rule will redirect any request to a .html file with a 410 Gone status code.
2. Redirect Query Strings:
`apache
RewriteEngine On
RewriteCond %{QUERY_STRING} .
RewriteRule ^ – [R=410,L]
`
This rule will redirect any request with a query string to a 410 Gone status code.
3. Redirect Posts or Categories:
`apache
RewriteEngine On
RewriteRule ^category/(.+)/$ – [R=410,L]
RewriteRule ^(.+)/$ – [R=410,L]
`
These rules will redirect requests to specific post or category URLs to a 410 Gone status code.
Please note that applying 410 redirects should be done with caution, as it indicates that the requested resource is permanently gone and will no longer be available. Make sure to thoroughly review and test your redirect rules before implementing them on a live website.
bettykingParticipant410 Gone status code indicates that the requested resource has been intentionally removed and is not available anymore. This is different from a 404 Not Found io games, which may mean the resource was either intentionally or unintentionally removed.
When a link/URL/URI has been permanently moved to a new location, a 301 Moved Permanently redirect should be used, not a 410 Gone. The 301 redirect tells the client (e.g., web browser) that the resource has been permanently moved to a new URI.
Properly using the correct HTTP status code (410 vs 404 vs 301) helps provide accurate information to clients and search engines about the status of a resource, which is important for maintaining a good user experience and proper website management.
MonicaSwiftParticipantDiscover the convenience of instant gaming at unblocked games, where you can explore a collection of online titles. With no downloads required, you can jump straight into the action and start playing within seconds.
-
AuthorPosts
- You must be logged in to reply to this topic.