Troubleshoot an htaccess problem

17 replies
I'm a bit of a beginner when it comes to this htaccess stuff but I read around the topic here and elsewhere and thought I had come up with a solution... sadly it ain't working.

here is an extract of the htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^solwaytimberengineering.co.uk
RewriteRule (.*) http://www.solwaytimberengineering.co.uk/$1 [R=301,L]
Redirect 301 http://www.solwaytimberengineering.co.uk/home.html [url=http://www.solwaytimberengineering.co.uk[/url]
Redirect 301 Joinery manufacturers|sash windows|wood door|Solway Timber Engineering Joinery manufacturers|sash windows|wood door|Solway Timber Engineering

There are several pages of old content which I am trying to redirect to their new versions. I suspect 1 of 3 things:
a) it's to do with the fact the site was built in directories for each page;
b) the space characters in the URLs; or
the host server isn't allowing rewrite.

The site owner wnated the site to stay on www.so I have also trioed to canonicalise everything to www.

Any tips would be much appreciated.

Forgot it wouldn't let me send URLs up yet. If anyone can help I'll upload a segment of the file.
Cheers,
Ray
#htaccess #problem #troubleshoot
  • Profile picture of the author cgimaster
    Can you put your htaccess code between code tags and remove the links so it is clear to read your current htaccess and possible see what the issue is ?
    {{ DiscussionBoard.errors[7287501].message }}
  • Profile picture of the author Mkj
    Try this:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^solwaytimberengineering.co.uk[nc]
    RewriteRule ^(.*)$ http://www.solwaytimberengineering.co.uk/$1 [r=301,nc]
    Redirect 301 /home.html http://www.solwaytimberengineering.co.uk/joinerymanufacturers/STEJoineryProducts.html
    {{ DiscussionBoard.errors[7288926].message }}
    • Profile picture of the author RayCassidy
      Originally Posted by Mkj View Post

      Try this:

      Code:
      Options +FollowSymLinks
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^solwaytimberengineering.co.uk[nc]
      RewriteRule ^(.*)$ http://www.solwaytimberengineering.co.uk/$1 [r=301,nc]
      Redirect 301 /home.html http://www.solwaytimberengineering.co.uk/joinerymanufacturers/STEJoineryProducts.html
      I've tried that out for the home.html file and it has worked just luvverly. Thankyou for that Mkj.

      I presume that I should just apply that logic now to the rest of the redirects even though they are in their own little folders?
      Ray
      {{ DiscussionBoard.errors[7304779].message }}
  • Profile picture of the author RayCassidy
    Hi cgimaster, sorry I didn't pick up on this quicker, been buried in stuff after a house move. Many thanks for responding. In the code snippet below, I have replaced the "http etc. domain dot co dot uk" with WWW-DOMAIN and in one instance where I am trying to set canonical url I have used NON-WWW-DOMAIN. I hope that that is clear. The remainder of the urls to different pages have been left in so that you guys might be able to tell me whether I have created a mistake or problem in the rest of the URL structure. In essence I am trying to redirect traffic from an old rather poor version of a page, to a better optimised version of the page's information.

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^NON-WWW-DOMAIN
     RewriteRule (.*) WWW-DOMAIN/$1 [R=301,L]
    Redirect 301 WWW-DOMAIN/home.html WWW-DOMAIN
    Redirect 301 WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 WWW-DOMAIN/Design%20Services/Design%20Services.html WWW-DOMAIN/timberframedesign/timberframedesignSTE.html
    Redirect 301 WWW-DOMAIN/Timber%20Kits/Timber%20Kits.html WWW-DOMAIN/timberframe/timberframehousekits.html
    Redirect 301 WWW-DOMAIN/Roof%20Trusses/Roof%20Trusses.html WWW-DOMAIN/rooftrusses/Roof-TrussesSolwayTimberEngineering.html
    Redirect 301 WWW-DOMAIN/Floor%20Cassettes/Floor%20Cassettes.html WWW-DOMAIN/floorcassettes/FloorCassettesSTE.html
    Redirect 301 WWW-DOMAIN/Joinery%20Products/Joinery%20Products.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 WWW-DOMAIN/Quality%20Assurance/Quality%20Assurance.html WWW-DOMAIN/qualityassurance/Quality%20Assurance.html
    Redirect 301 WWW-DOMAIN/Enviromental%20Policy/Environmental%20Policy.html WWW-DOMAIN/enviromentalpolicy/Environmental%20Policy.html
    Redirect 301 WWW-DOMAIN/Our%20HIAB/Our%20HIAB.html WWW-DOMAIN/STE-HIAB/Our%20HIAB.html
    Redirect 301 WWW-DOMAIN/Our%20People/Our%20People.html WWW-DOMAIN/STEpeople/Our%20People.html
    Many thanks for offering your experience.
    Ray
    {{ DiscussionBoard.errors[7304749].message }}
  • Profile picture of the author cgimaster
    Your problem is that you are doing:

    domain/link on the first step of the Redirect 301 while it should be only the path.

    Code:
    Redirect 301 /home.html WWW-DOMAIN
    Redirect 301 /joinerymanufacturers/STEJoineryProducts.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 /Design%20Services/Design%20Services.html WWW-DOMAIN/timberframedesign/timberframedesignSTE.html
    Redirect 301 /Timber%20Kits/Timber%20Kits.html WWW-DOMAIN/timberframe/timberframehousekits.html
    Redirect 301 /Roof%20Trusses/Roof%20Trusses.html WWW-DOMAIN/rooftrusses/Roof-TrussesSolwayTimberEngineering.html
    Redirect 301 /Floor%20Cassettes/Floor%20Cassettes.html WWW-DOMAIN/floorcassettes/FloorCassettesSTE.html
    Redirect 301 /Joinery%20Products/Joinery%20Products.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 /Quality%20Assurance/Quality%20Assurance.html WWW-DOMAIN/qualityassurance/Quality%20Assurance.html
    Redirect 301 /Enviromental%20Policy/Environmental%20Policy.html WWW-DOMAIN/enviromentalpolicy/Environmental%20Policy.html
    Redirect 301 /Our%20HIAB/Our%20HIAB.html WWW-DOMAIN/STE-HIAB/Our%20HIAB.html
    Redirect 301 /Our%20People/Our%20People.html WWW-DOMAIN/STEpeople/Our%20People.html
    Also you may need to scape the % symbol not entirely sure but if it doesnt work add before each % this \
    {{ DiscussionBoard.errors[7305208].message }}
    • Profile picture of the author RayCassidy
      cheers cgi I'll try that out now. funny how the home.html worked fine. ?
      Ray
      {{ DiscussionBoard.errors[7305268].message }}
      • Profile picture of the author cgimaster
        Originally Posted by RayCassidy View Post

        cheers cgi I'll try that out now. funny how the home.html worked fine. ?
        Ray
        As I can see above ONLY the home.html is without domain as /home.html on the first step all the others have domain/path.
        {{ DiscussionBoard.errors[7305894].message }}
        • Profile picture of the author RayCassidy
          Are you looking at the first version or the later version cgi? In the second version I have taken out the domain statement in the first step of each url (as far as I understand this) and next thing to try will be escaping the spaces(?) I presume that's what you meant.
          Many thanks for your time.
          Ray
          {{ DiscussionBoard.errors[7306777].message }}
        • Profile picture of the author RayCassidy
          Are you looking at the first version or the later version cgi? In the second version I have taken out the domain statement in the first step of each url (as far as I understand this) and next thing to try will be escaping the spaces(?) I presume that's what you meant.
          Many thanks for your time.
          Ray
          {{ DiscussionBoard.errors[7306805].message }}
  • Profile picture of the author cgimaster
    Code:
    Redirect 301 WWW-DOMAIN/home.html WWW-DOMAIN
    Redirect 301 WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 WWW-DOMAIN/Design%20Services/Design%20Services.html WWW-DOMAIN/timberframedesign/timberframedesignSTE.html
    Redirect 301 WWW-DOMAIN/Timber%20Kits/Timber%20Kits.html WWW-DOMAIN/timberframe/timberframehousekits.html
    Redirect 301 WWW-DOMAIN/Roof%20Trusses/Roof%20Trusses.html WWW-DOMAIN/rooftrusses/Roof-TrussesSolwayTimberEngineering.html
    Redirect 301 WWW-DOMAIN/Floor%20Cassettes/Floor%20Cassettes.html WWW-DOMAIN/floorcassettes/FloorCassettesSTE.html
    Redirect 301 WWW-DOMAIN/Joinery%20Products/Joinery%20Products.html WWW-DOMAIN/joinerymanufacturers/STEJoineryProducts.html
    Redirect 301 WWW-DOMAIN/Quality%20Assurance/Quality%20Assurance.html WWW-DOMAIN/qualityassurance/Quality%20Assurance.html
    Redirect 301 WWW-DOMAIN/Enviromental%20Policy/Environmental%20Policy.html WWW-DOMAIN/enviromentalpolicy/Environmental%20Policy.html
    Redirect 301 WWW-DOMAIN/Our%20HIAB/Our%20HIAB.html WWW-DOMAIN/STE-HIAB/Our%20HIAB.html
    Redirect 301 WWW-DOMAIN/Our%20People/Our%20People.html WWW-DOMAIN/STEpeople/Our%20People.html
    NONE of the above work, why ? because you have after 301 the domain instead of the path alone.

    Why does the home.html work in there ?

    The home.html is not working from those it is working from your main condition at:
    Code:
    RewriteCond %{HTTP_HOST} ^solwaytimberengineering.co.uk[nc]
    RewriteRule ^(.*)$ http://www.solwaytimberengineering.co.uk/$1 [r=301,nc]
    To put it simple, the Redirect syntax is as follow:

    Redirect 301 PATH DESTINATION

    Where PATH is the path after the domain of what you want to redirect.

    So let's say you want to redirect www.mydomain.com/rosesarered.html to www.mydomain.com/roses.php, it will look like this:

    Code:
    Redirect 301 /rosesarered.html www.mydomain.com/roses.php
    and next thing to try will be escaping the spaces(?) I presume that's what you meant.
    In regards the space, you can use it like this:

    Code:
    Redirect 301 "/Design Services/Design Services.html" WWW-DOMAIN/timberframedesign/timberframedesignSTE.html
    See how I am wrapping it around double quotes and replacing %20 with a normal space ? I have tested it and works just fine.

    You can always check the mod_rewrite file in your ftp to catch any errors, sometimes its saved all inside error_log file in case it fails the error message might be helpful to nail what is the problem.
    {{ DiscussionBoard.errors[7306915].message }}
    • Profile picture of the author RayCassidy
      Thanks cgi - I appreciate you taking the time to explain to me. It's one of those mental blocks that just refuse to go away . I will have a go at your instructions later this evening.
      Cheers muchly,
      Ray
      {{ DiscussionBoard.errors[7308577].message }}
      • Profile picture of the author carleywatson
        you can change of .htaccess into htaccess.text.your problem maybe solve.








        if you need fly to Kuala Lumpur from London at dearflight
        {{ DiscussionBoard.errors[7308734].message }}
      • Profile picture of the author cgimaster
        Originally Posted by RayCassidy View Post

        Thanks cgi - I appreciate you taking the time to explain to me. It's one of those mental blocks that just refuse to go away . I will have a go at your instructions later this evening.
        Cheers muchly,
        Ray
        No problem, if you want I can assist you further on skype and see how things are going for you just drop me a pm or post here either way works, GL.
        {{ DiscussionBoard.errors[7309293].message }}
  • Profile picture of the author RayCassidy
    Hi cgi - just a quick update, I still haven't taken action on this, as other circumstances landed on me. I've just about crawled out from under that pile of rubble. I will be speaking to the business owner of the website tomorrow and hopefully will put into action what you have suggested fairly soon.
    Many thanks again.
    {{ DiscussionBoard.errors[7336319].message }}
    • Profile picture of the author cgimaster
      Originally Posted by RayCassidy View Post

      Hi cgi - just a quick update, I still haven't taken action on this, as other circumstances landed on me. I've just about crawled out from under that pile of rubble. I will be speaking to the business owner of the website tomorrow and hopefully will put into action what you have suggested fairly soon.
      Many thanks again.
      No problem feel free to contact me if u have any other questions.
      {{ DiscussionBoard.errors[7337850].message }}
  • Profile picture of the author RayCassidy
    Hi cgi the tale continues. I finally got the thing working with that advice about escaping the spaces, Many many thanks for taking the time to explain to an old fart! ;-)
    {{ DiscussionBoard.errors[7353613].message }}
  • Profile picture of the author cgimaster
    Glad it worked well for you anything let me know.
    {{ DiscussionBoard.errors[7353779].message }}

Trending Topics