How to redirect to subfolder based on matching two words from the query.

Discussion in 'Apache' started by tommytx, Apr 11, 2011.

  1. #1
    Wow i have been messing with this simple thing all night and reading all your posts on htaccess and still have no positive results.

    Sample 1 URL:
    http://www.mydomain.com/?s=no-results:no-results:sharon milligan&cat=no-results

    Sample 2 URL:
    http://www.mydomain.com/?s=no-results:no-results&cat=no-results

    # Begin of my htaccess file.
    options all
    RewriteEngine on
    RewriteBase /
    ReWriteRule no-results /idx/test.php [L]

    # Mandatory wordpress code that must stay in place.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule html /cgi-bin/index.pl [L]
    RewriteRule ^$ /index.html
    # End of mandatory Wp code.

    # End of my htaccess file.



    # Some other things I tried..
    # RewriteCond %{QUERY_STRING} ^=no-results$
    # RewriteRule ^.*$ /idx/test.php [L]



    I have a ton of this junk indexed in google, and what I want to do is detect them when the come in by human or by google and forward them to a real url so they will be indexing real stuff and if a human will show them real stuff.
    That is what the file test.php does, sends them to a nice page. Then logs that page so if the client comes back or google checks up it will return them the same page over and over.

    1. As you can see the only thing that is guaranteed to be constant is the first "no-results" so I want to check the Query for the word "no-results" and if there forward to the idx subdirectory for processing. If not continue on their merry way. I have included the Wordpress code just in case someone has suggestions as to the best place to position the code in the actual htaccess file. I assume its best to place it before the wp code.. since if its valid the wordrpess page will never load. Hopefull the [L] following the code will prevent the wordpress code from running if it is a valid page. Meaning the url has the word no-results.

    2. only 2 sample urls are shown, but there are many but they all have the first "no-results" at the beginning of the query.
     
    tommytx, Apr 11, 2011 IP