Having trouble setting up redirects in your cPanel for your WordPress website?
It won’t work by just adding the redirects to your cPanal, but it’s not that hard to fix. Scroll down to the solutions!
First Off – What is cPanel and what is a Redirect?
cPanel is a great hosting control panel interface. My favorite commercial option. And WordPress is a wonderful content management system (CMS), so much so that more websites are running on it than on any other CMS word wide.
So let’s say you just built a new website for yourself or a client, and you are hosting the new site on a host using cPanel.
Let’s say that your old website was programmed in straight HTML or PHP or any other variety other than one that ends in the same fashion as your new WordPress site ends. The result might be something like this for your About Us page:
Old site:Â http://mysite.com/about-us.html
New site: http://mysite.com/about-us/
Now some people may have a bookmark to your old site, to that specific page. And search engines have your about us page ranked at that old url. But when someone goes to http://mysite.com/about-us.html they are going to get an error page – because that page does not exist.
In comes the redirect.
The redirect allows you to make it so that anyone going to http://mysite.com/about-us.html is automatically redirected to http://mysite.com/about-us/. Great. Problem solved. And a permanent redirect (301) will tell search engines that this is the new location for that old website address. Perfect.
So let’s just go into our cPanel and create a redirect. (If you know how to edit an .htaccess file, then of course you could go in and do that, but if you are reading this, you likely do not know how to format such a statement in your .htaccess file to tell it to do what you want – or you want the convenience of the cPanel interface to make it easier.)
How to create a Redirect in cPanel.
- In cPanel click on the Redirect option (you can search for it at the top of cPanel).
- Select the Type, Permanent or Temporary.
- Select if you want to apply the redirect to all of the domains in your hosting account or just one.
- After the / type in the url extension you wan to redirect from. (In our example above where we are redirecting from http://mysite.com/about-us.html we would enter: about-us.html
- Enter the full url you want to enter to. (In our example above we would enter: http://mysite.com/about-us/).
- Choose what to redirect, with www or not or both. If you are not sure leave it at its default of both.
- Tick WildCard redirect (see comment on page describing what this is) and click Add.
- Test it by going to the original URL in your browser.
So you create your redirect in the cPanel – and it DOES NOT WORK. Ugh!
First Tip
Be sure you entered the url extension properly after the “/”. In the case where you might be wanting to redirecting:
From:Â http://mysite.com/about-us/
To: http://mysite.com/about/
Be sure you enter:
about-us/
after the / and not just:
about-us
The More Common Problem & Solution
You do have to edit the .htaccess file, but nothing complex. Let’s take a look. Here is the code from a WP install .htaccess file:
RewriteOptions inherit
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^main.htm$ "http://mydomain.com/" [R=301,L]
Just take the part that wraps around the WordPress part, and move it to the end, after the newly added Rewrite rule(s). And it will look like this:
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^main.htm$ "http://mydomain.com/" [R=301,L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
That is it.
Well, if you don’t know how to edit your .htaccess file, here are a few tips.
In your cPanel click on the File Manager. Once there click the “Settings” button at top right of the panel and tick the box to “Show Hidden Files”. Now you should be able to see that file in the root of your files, in the same location as where your wp-content folder is. You can click it once and click Edit to edit. Or you can download and edit on your computer and upload again.
Good luck. Let me know below if this helped!
14 thoughts on “WordPress, cPanel, Redirects and htaccess”
THANK YOU!!!!
This was doing my head in!!!
Was having redirect problems on a new site for a client and looked all over the place for a solution. I can’t believe this post is from 2012 and it still worked for me! Problem solved. Thank you for the post and providing such a clear explanation on how to make the changes.
glad it helped.
Thanks for the tip. Is there a way to keep it at the end? It gets bumped up and then redirects dont work agin.
There may be, but I do not think so.
Hi
I placed a rewrite/redirect rule in my cpanel to redirect my blog http://www.wildflowersaromatherapy.com/blog/ to my website. I have searched through all the .htaccess files and can’t find the redirect culprit.
Is there any way you know of to search all the cpanel files and folders for this lost redirect code.
I can open up my http://www.wildflowersaromatherapy.com/blog/ but anything after the trailing / gets redirected. Hope you can help.
Thanks
Peter
Hi Peter,
If you added that rule via your cpanel, I believe it would have been added to the .htaccess file in the root of your domain name directly at http://www.wildflowersaromatherapy.com. Do you look there and not find any such rule? And did you look in your cpanel and see if you can remove it in the same cpanel pane as you created it? Otherwise, you could contact your hosting provider and see if they can fix it for you. I am guessing from what you shared that your intent is to remove the rewrite rule you created?
Pingback: How to Redirect Users to a Different URL | Hybrid Self-Publishing
Thanks for providing the missing piece of the puzzle. As I was setting up some redirects using cPanel and documenting the process to help my blog’s readers, I thought I had done everything correctly but the redirects were not working. I had seen several posting talking about how to code a redirect on the htaccess file, but that seemed beyond my ability. Thankfully I found your post and the simple procedure for modifying the htaccess file to move the WordPress text after the Rewrite rules.
I’ve provided the step-by-step checklist at http://www.petenikolai.com/page-redirect/ including how to use cPanel’s Redirects utility to create the redirects and how to use File Manager to find and edit htaccess.
Always nice to see someone benefiting from blog posts.
Hello David,
I am doing this method for my client website and its working. But now my client planning to make more redirects and he will set up this with the cpanel. Each time he will add a redirect through cpanel it will fail and I need to move these redirect rule to above wordpress entries to work this. He need not want to contact me all the time to add these redirects. How he can add redirects through cpanel .
Kind regards
Rinshad
I am glad this helped you. Unfortunately the only way I could think of that he could do this via cPanel is for you to tell him how to edit the htaccess file via the filemanager. And perhaps to save a backup copy each time in case he makes an error in the htaccess file.
Thanks very much. I searched for hours – I knew there was a workaround and as always its something obvious 🙂 Much appreciated
No sweat.