Skip links
Published on: Website

WordPress .htaccess redirect

WordPress .htaccess redirect

WordPress .htaccess redirect and it’s work.

WordPress.org is a very famous site. And easy to use as well. It has so many files which help you grow your site. Just like that .htaccess is an important WordPress file. This file helps us in the modification of severing and configuration, security and performance parameters. In case you are looking forward to resolving your server issues. You can just update or edit the WordPress file .htaccess.

Strange but true. Not many users are aware of the magic .htaccess file can do. The lack of knowledge about the .htaccess file. It becomes the reason that owners can not take advantage of its awesome feature. You can easily edit your .htaccess file rules and optimize your site’s server.

How to edit .htaccess

To edit you first need FileZilla or any FTP client you use. You need an FTP client to read your files. Then move to your root directory. Log in to the web hosting account from the cPannel. Move to  ‘public_html’ folder. In this folder click on .htaccess file. A menu will open click on View/Edit. Now, edit changes and save.

WordPress .htaccess redirect

WordPress allows its users to control website redirects. Below are six rules which can help you set up controls for your WordPress website redirects.

301 Redirect

301 redirect is permanent. Search engine shows that the URL of your site. Has been permanently moved to another place/location. You may experince the same for folder, page, posts. Sometimes on your website as well. You can edit this snippet given below. To redirect ypur old page to new page.

Redirect 301 /oldpage.html http://www.yourwebsite.com/newpage.html

302 Redirect

302 redirect is temporary. Because the search engine shows. Redirection of the subject is temporary. If you are facing issues with SERP shuffles. Then the 302 redirects will help you. By this SERP shuffles will get slow-down. All you need to do is edit a line to the .htaccess file. Replace focus word with your site.

Redirect 302 /oldpage.html http://www.yourwebsite.com/newpage.html

Force URL to www

This rule helps you force visitors to use www.xyz.com instead of xyz.com. Replace focus word with your site.

RewriteEngine on RewriteCond %{HTTP_HOST} ^xyz.com [NC] RewriteRule ^(.*)$ http://www.xyz.com/$1 [L,R=301,NC]

Force HTTPs

Generally, visitors use HTTP. This rule will force your visitors. To use https for your URLs.

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} ^https$ RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}

Redirect of Domain to Sub-directory

To redirect your domain URL. To your sub-directory. You can use the rule given below.

RewriteCond %{HTTP_HOST} ^example.com$ RewriteCond %{REQUEST_URI} !^/sub-directory-name/ RewriteRule (.*) /subdir/$

Redirect URL

Suppose you have two domains. And one website. Both domains are running om same site. You can use this rule.

Redirect 301 / http://www.mynewwebsite.com/

Force URL (non-www)

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Force HTTP

This rule will help you force. http instead of https.

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} ^https$ RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}

Note: Any comma, full-stop, brackets or symbol removed. Can take down your site. Be careful using them.

Thankyou for visiting us, keep reading and learning.

Leave a comment