0

This is driving me crazy, can anybody tell me why this 301 redirect does not work. I just get a 404 error with the old /about page. Here is the code for info:

{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" [L]
</IfModule>
# END WP Rocket

RewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 301 /about https://scottcarneyphotography.com/about
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteEngine on
2
  • The directives you've posted are not complete - the first few look like they have been cropped? What redirect are you trying to do exactly? I can see one redirect from /about to /about - which obviously doesn't make a whole lot of sense?! Is that on a different domain or the same domain? You have other errors (directives in the wrong order) and other seemingly superfluous directives?
    – MrWhite
    Commented Dec 29, 2018 at 12:35
  • the redirect is from one domain where the htaccess file is located. /about then it is redirecting to the new domain which is scottcarneyphotography.com/about so the bit I added is the following. Redirect 301 /about scottcarneyphotography/about Commented Dec 29, 2018 at 13:37

2 Answers 2

2
Redirect 301 /about https://scottcarneyphotography.com/about

The Redirect directive belongs to mod_alias and consequently runs after the existing mod_rewrite directives in your config file, this is possibly resulting in a conflict.

You should move this redirect to the top of your .htaccess file and convert it to mod_rewrite instead. For example:

RewriteRule ^about$ https://scottcarneyphotography.com/about [R=301,L]

However, there are other potential issues with your .htaccess file...

{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" [L]
</IfModule>
# END WP Rocket

I guess you're not showing your complete config file, however, these directives are literally chopped in half - so they don't look valid. There may also be directives earlier in the file that may conflict with your redirect.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

These directives (at the end of the .htaccess file, after the WordPress front-controller) are in the wrong place and consequently will not work as intended (to redirect all traffic to HTTPS). They should be near the top of your .htaccess file, before the WordPress front-controller.

RewriteEngine on

There's no need for spurious/multiple RewriteEngine directives strewn, seemingly arbitrarily, throughout the config file. You only need one of these. (Keep the one inside the # BEGIN WordPress block.)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
:
</IfModule>
# END WordPress

You should avoid manually editing the directives between the # BEGIN WordPress and # END WordPress comment markers. This is maintained by WordPress, so could be overwritten by WordPress in future updates (unless you have explicitly blocked WP from doing this).

1

Check please if add to top .htaccess file (before WP Rocket rewrites) this 301 redirect work.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^about\/$ https://scottcarneyphotography.com/about/ [R=301,L]
</IfModule>

Wordpress default add / to end of URL address, maybe request is /about/ not /about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.