htaccess redirect code – redirect old page to new page

Home Forums BulletProof Security Free htaccess redirect code – redirect old page to new page

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #24721
    AITpro Admin
    Keymaster

    We merge topics that are relevant/similar to each other, otherwise there would be 10 times as many forum topics in this forum site and then what happens is when someone uses the forum search feature they would see 10 times as many search results.  Basically that would take away from the usefulness of the forum search feature because it would make finding things difficult and time consuming.  So overall it is better to organize things that are similar to each other. 😉

    Oh ok got want you want to do.  This is the code you are looking for:

    # Redirect do=contactus & do=detailpage Query Strings to /ads/ 
    # & strip the Query Strings from the destination URI
    RewriteCond %{QUERY_STRING} ^do=contactus$ [NC,OR]
    RewriteCond %{QUERY_STRING} ^do=detailpage(.*)$ [NC]
    RewriteRule ^(.*)$ /ads/$1? [R=301,L]
    #24724
    Adendum
    Participant

    OK, I understand the merging … I just find it confusing. The code appears to refer to a couple of the 404’s I first listed but I have hundreds of them. The are all different, which implies I need to manually code each 404 URL? Is there any way to simply say every request for /classifieds/ (no matter what comes after the /) are all sent to /ads/

    #24725
    AITpro Admin
    Keymaster

    The Forum Show Topics & Replies Search Filter allows you to search for text/strings within topics and replies so if you are looking for something specific then you will find it.  I use this search filter every day, all day otherwise I would never be able to find old solutions to things. 😉  You can just use this code below if all of the Query Strings start with do= and nothing else on your site uses that Query String.

    # Redirect all Query Strings that start with do= to /ads/ 
    # & strip the Query Strings from the destination URI
    RewriteCond %{QUERY_STRING} ^do=(.*)$ [NC]
    RewriteRule ^(.*)$ /ads/$1? [R=301,L]

    If you want to make sure that ONLY Request URI’s with “classifieds” do the Query String strip and redirect then this is the code that you want:

    # Redirects ONLY if the URI is classifieds/ and Strips the do= Query Strings
    # from the destination /ads/ URL|URI
    RewriteCond %{QUERY_STRING} ^do=(.*)$ [NC]
    RewriteRule ^classifieds/$ http://www.example.com/ads/$1? [R=301,L]
    #24735
    Adendum
    Participant

    Thanks again – I do appreciate the help you are giving me!! I tried the code suggested and then clicked a 404 link in Google webmaster and it almost works…. Once clicked the result takes you to a URL of http://www.domain.net/ads/classifieds/ – so a new 404 is generated 🙁 What I want to do is change this link (and all like it) ..http://www.domain.net/classifieds/?do=detailpage&cat=3&id=14 tohttp://www.domain.net/ads/ 

    #24737
    Adendum
    Participant

    But the second bit of code works! So I’m happy – learnt a lot, still confused by rewrites though! But very appreciative of your help!

    #24739
    AITpro Admin
    Keymaster

    Good job!

Viewing 6 posts - 16 through 21 (of 21 total)
  • You must be logged in to reply to this topic.