WordPress.org

Ready to get started?Download WordPress

Forums

.htaccess issues when applying a rewriteRule... (10 posts)

  1. caravanguard
    Member
    Posted 2 years ago #

    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

  2. BeautyPirate
    Member
    Posted 2 years ago #

    RedirectMatch 301 /park-home-insurance/faqs/(.*)$ /knowledgebase/$1

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

  3. caravanguard
    Member
    Posted 2 years ago #

    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.

  4. caravanguard
    Member
    Posted 2 years ago #

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

    Even this won't work either

  5. BeautyPirate
    Member
    Posted 2 years ago #

    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.

  6. caravanguard
    Member
    Posted 2 years ago #

    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]
  7. 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.

  8. caravanguard
    Member
    Posted 2 years ago #

    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
  9. 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.

  10. caravanguard
    Member
    Posted 2 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic