Support » Fixing WordPress » .htaccess issues when applying a rewriteRule…

  • Hello All I am trying to perform a rewrite via Htaccess but I am having some issues… I reently replaced another dev in the role I am in and she did the previous install of WP i am working on.

    We have an installation in /knowledgebase

    But I would like it if I could use another url /park-home-insurance/faqs/

    my rewrite rule looks like so…

    RewriteRule ^park-home-insurance/faqs/(.*)$ knowledgebase/$1/?cat=3 [NC,QSA,L]

    Does the above look right as I keep being sent to my 404.

    my permalink is a custom generated using %postname%…

    Any help would be wonderful..

    Regards all

    Tim

Viewing 9 replies - 1 through 9 (of 9 total)
  • RedirectMatch 301 /park-home-insurance/faqs/(.*)$ /knowledgebase/$1

    That should do it. If it doesnt work use full http urls.

    Cheers BeautyPirate,

    Although that does work by redirecting I wanted to keep the url structure as per the rest of the site I am working with. Hence looking at the RewriteRule as the best option…

    However, thank you ever so much for your solution above. I shall utilise this should I not find another method.

    RewriteRule ^/park-home-insurance/faqs/$ http://www.domain.co.uk/knowledgebase/ [R=301]

    Even this won’t work either

    Some web servers donĀ“t allow the: ^ symbol which indicates the beginning of the url. (Has to do with how deep you can access your webserver.) Try to leave that symbol out, that did the trick for me.

    Still nothing seems to budge :o( I have removed the ^ symbol.

    this is my new version of the htaccess rules

    RewriteEngine On
    Options +FollowSymLinks
    RewriteBase /
    
    #Park Homes FAQ Rule
    RewriteRule /park-home-insurance/faqs/$ 			http://www.leisuredays.co.uk/knowledgebase/ [R=301,NC,QSA,L]
    RewriteRule /static-caravan-insurance/faq/$ 		http://www.leisuredays.co.uk/knowledgebase/ [R=301,NC,QSA,L]
    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    I think it’s the leading / that might be causing it not to work.

    Try this instead.

    RewriteEngine On
    RewriteBase /
    #Park Homes FAQ Rule
    RewriteRule ^park-home-insurance/faqs/$ http://www.leisuredays.co.uk/knowledgebase/ [R=301,L]
    RewriteRule ^static-caravan-insurance/faq/$ http://www.leisuredays.co.uk/knowledgebase/ [R=301,L]
    
    # BEGIN WordPress

    And of course, put that above your WordPress rules.

    I thought we had cracked it for a minute there Jan. But alas I am afraid it is still not working :o( 404 is showing instead.

    Could it be conflicting with any other .htaccess files created by WP…

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /knowledgebase/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /knowledgebase/index.php [L]
    </IfModule>
    # END WordPress
    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    Could it be conflicting with any other .htaccess files created by WP…

    Not if you put them above those rules, but I think I see what it might be.

    You have WordPress installed in /knowledgebase/? I don’t think those additional rules will work there, they need to be handled in /.

    If there is no existing .htaccess file in your / directory, try placing this there.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #Park Homes FAQ Rule
    RewriteRule ^park-home-insurance/faqs/$ http://www.leisuredays.co.uk/knowledgebase/ [R=301,L]
    RewriteRule ^static-caravan-insurance/faq/$ http://www.leisuredays.co.uk/knowledgebase/ [R=301,L]
    </IfModule>

    If there is one already then make a backup copy first and get ready to undo any of your changes quick. Just in case.

    Thank you Jan, I already had it all in root as well…

    It has however made some progress. which is great :o) however I was expecting that when you when to park-home-insurance/faqs that it would display the content from Knowledgebase – or have I got it the wrong way around… I wasnt wanting to redirect.

    Cheers

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘.htaccess issues when applying a rewriteRule…’ is closed to new replies.