Unsure how to rewrite htacess to include 301 redirects... (Multiple RewriteEngine ons?)

16 Views Asked by At

I am VERY novice on this, having used 301 redirects for other websites a few times. This time, the website has an existing htaccess file that has some "bad bots" directives. Here is a sample (it's a LOOOONG list of bots):

Options -Indexes
# BEGIN Refuse Bad Bot
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ".*SemrushBot.*" [OR]
    RewriteCond %{HTTP_USER_AGENT} ".*AhrefsBot.*" [OR]
    RewriteCond %{HTTP_USER_AGENT} ".*ZyBorg.*"
    RewriteRule ".*" "-" [F]
</IfModule>
# END Refuse Bad Bot

I want to keep this and add 301 redirects. Should I add another RewriteEngine on (esp since the first one SEEMS (to this novice) to be within an IF/THEN statement that won't apply to my 301's.

I assume I should do the following, but not sure if this is correct:

Options -Indexes
# BEGIN Refuse Bad Bot
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ".*SemrushBot.*" [OR]
    RewriteCond %{HTTP_USER_AGENT} ".*AhrefsBot.*" [OR]
    RewriteCond %{HTTP_USER_AGENT} ".*ZyBorg.*"
    RewriteRule ".*" "-" [F]
</IfModule>
# END Refuse Bad Bot

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

Redirect 301 /old-page-1/ https://www.example.com/new-page-1/
Redirect 301 /old-page-2/ https://www.example.com/new-page-2/
Redirect 301 /old-page-3/ https://www.example.com/new-page-3/

Any help would be appreciated.

** ALSO: I think it is better not to include "/index.html" at the end of the 301's (old or new) for better results? Did I read that correctly somewhere?

"I'm a designer, not a programmer, Jim!" – Dr. L McCoy

0

There are 0 best solutions below