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

Reply To: htaccess Redirect Code – Where Do I Add Redirect htaccess Code

$
0
0

Yep, Query Strings are tricky due to the way all Browsers are designed to interpret/handle/process Query Strings, which start with the question mark to signify processing/handling of a Query String instead of a Browser seeing the question mark as a literal character in a URL|URI.  So the htaccess code that you want to use is this example code below:

Strips all Query Strings that start with do= ONLY if the Request URI is classifieds/ and redirects to the /ads/ URI:  http://www.example.com/classifieds/?do=detailpage&cat=3&id=14 to http://www.example.com/ads/ 

# Redirects ONLY if the URI is classifieds/ and Strips the do= Query Strings
# from the destination /ads/ URL|URI
RewriteCond %{QUERY_STRING} ^do=(.*)$ [NC]
RewriteRule ^classifieds/$ http://www.example.com/ads/$1? [R=301,L]

If you are just trying to redirect all old URL’s|URI’s to one place/any new URL|URI on the new site just to get rid of any/all 404 errors from the old site then you can just use this code: RedirectMatch 301 ^/(.*)$ http://www.example.com/

If you are trying to redirect old URL’s|URI’s to new specific URL’s|URI’s your actual code would probably be something like this and since this code is going to be in the htaccess file on the “old site” then you do not have to factor in that it would impact/affect the URI’s on the new site.

RewriteCond %{QUERY_STRING} ^p=164$ [NC]
RewriteRule ^(.*)$ http://www.example.com/new-page-or-post-url/$1? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=6320$ [NC]
RewriteRule ^(.*)$ http://www.example.com/another-new-page-or-post-url/$1? [R=301,L]
RewriteCond %{QUERY_STRING} ^p=2357$ [NC]
RewriteRule ^(.*)$ http://www.example.com/some-other-new-page-or-post-url/$1? [R=301,L]
  • This reply was modified 17 hours, 44 minutes ago by Profile photo of AITpro Admin AITpro Admin.
  • This reply was modified 17 hours, 43 minutes ago by Profile photo of AITpro Admin AITpro Admin.

Viewing all articles
Browse latest Browse all 12488

Trending Articles