301 redirect in the htaccess file issues

301 redirect in the htaccess file issues - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the 301 redirect in the htaccess file issues error on your web browser. Problem :


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

Solution :


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).



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.


We hope that this article has helped you resolve the htaccess, redirects, 301-redirect error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

Redirected urls show in serp, with the original permalink but with the title and meta of the target page

How can I redirect everything but the index as 410?

How do I redirect traffic only if being accessed from a specific port?