Post by joshhpalmer » Tue Jul 25, 2017 6:02 pm

Hello,

I wonder if anyone can help me...

I am planning on updating the URL's of all the infrormation pages and category pages on my site but I need to set up 301 redirects to the new URL as some of these pages are ranking high in Google and do not want users to land on a 'page not found' page.

I have tried adding the 301 redirect using the 'Redirects' in cPanel - everything seems to be added okay but the redirects do not work. I've kept one in as an example...

I am trying to redirect the old URL http://cameronlee.co.uk/Cameron-Lee-Carpets-Gallery to the new URL http://cameronlee.co.uk/Gallery but when I go to the original URL, the redirect does not work.

Image

I've also tried adding the redirects manually in the .htaccess file in the FTP file manager, but again the redirect does not work:

Image

I've also tried using the Redirect 301 code in the .htaccess file rather than RewriteRule but this still does not work.

Does anyone have a solution as to why the redirect is not working?

Thanks

Newbie

Posts

Joined
Tue Jul 25, 2017 5:52 pm

Post by MrPhil » Tue Jul 25, 2017 9:15 pm

Well, your .htaccess is a mess! You have 4 Rewrite Conditions, of which either of the first two and both of the third and fourth have to be satisfied before it will even consider the Rewrite Rule.

First, simplify the first two RewriteConds into:

Code: Select all

RewriteCond  %{HTTP_HOST}  ^(www\.)?cameronlee\.co\.uk$
By the way, this is useful only if you are handling other domains and/or subdomains in the same account. If you have only cameronlee.co.uk, you can discard this check.

Your (currently) third RewriteCond will be true only if the URI is not /...cpandeldcv (which will always be true if you're trying to rewrite the Gallery URI), and the (currently) fourth RewriteCond will be true only if the URI is not /... Comodo DCV. Again, unnecessary for this Rewrite.

The RewriteRule itself can be cleaned up:

Code: Select all

RewriteRule ^Cameron-Lee-Carpets-Gallery$  /Gallery  [R=301,L]
It says if the URI is exactly /Cameron-Lee-Carpets-Gallery (plus any URL Query String schmutz), send to the current domain /Gallery, with a permanent redirect flag.

So, you should be able to eliminate all the RewriteConds, unless you might have an active one already open, and need to cancel it by setting a new one, or you handle multiple domains/subdomains and need to restrict it to this one.

Also, you have a RewriteEngine On somewhere above this? And don't use php_value and php_flag if your system supports a php.ini file -- these settings go in php.ini. Since you have cPanel, I'll assume that .htaccess is used on your system. And is this .htaccess in the site root (/.htaccess)? (not the filesystem root!)

Finally, please don't use images -- use copy and paste to grab screen content, and put it in a code tag, so we can quote your post and still see its content while replying.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm
Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 403 guests