The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 05:10:10 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: How to look into Request URI and see if some unque letters are there.  (Read 3964 times)
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« on: February 26, 2010, 05:06:06 AM »

I have a thousand special coded urls coming in and need to find some way to look at the Request URI and if the three uniqe characters exist then redirect to the /adwords directory and carry the request uri with you and also when you land keep the original url... do not change the url to the directory I am in now whch is adwords.

The below works perfect, but  of course i cannot plug the entire uri into the system each time so I put a special character to identify all 1,000 urls... the symbols are the _id_ which will be in every url.

RewriteCond %{REQUEST_URI} ^/vabe_forcl_13a_id_100003
RewriteRule ^(.*)$ /adwords/?id=$1


Here is the incoming URL: thousands in this format
hxxp://www.mydomain.com/ches_forcl_13a_id_100003
hxxp://www.mydomain.com/norf_forcl_13a_id_100004
hxxp://www.mydomain.com/vabe_forcl_13a_id_100005


So the letters I am trying to detect are located in the  Request URI. they are _id_" in every url like this..  "ches_forcl_13a_id_100003"

The only thing that remains constant all the time for every url is the "_id_" portion
So what I need to do is satisfy the condition if the url has "_id_"

Is there a way to evaluate it like the following...

RewriteCond strpos(%{REQUEST URI},=="_id_")

In other words is there a way to satisfy the condition if the characters _id_ is in the URI or in the url anywhere for that matter.

The Rewrite rule works ok if the conditon is met it goes to /adwords and keeps the URI attached.
And the url keeps the original look "http://www.vahud.com/ches_forcl_13a_id_100003" even though it is actually in the /adwords directory.

The way it is, the condition is met but only for the specific one..vabe_forcl_13a_id_100003 and I will need to match thousands of urls using the _id_ that will be in every url.


Logged
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« Reply #1 on: February 26, 2010, 05:40:25 AM »

Why cant you just go:
Code:
$conditionreached=strpos($_SERVER['REQUEST_URI'],'_id_');
if ($conditionreached===false){
  echo 'this one didnt have the _id_ in it';
} else {
  echo 'condition was reached';
}
Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #2 on: February 26, 2010, 06:41:28 AM »

RewriteCond %{REQUEST_URI} _id_
RewriteRule ^(.*)$ /adwords/?id=$1

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« Reply #3 on: February 26, 2010, 07:03:29 AM »

doh! ok... not even php... outta my league here.
Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: February 26, 2010, 12:32:12 PM »

You might want to add [L] to make that the last rule. I also don't know if [QSA] would make things go better.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #5 on: February 26, 2010, 05:14:52 PM »

Thanks Perkiset, I knew you would have a quick answer... works great..
I always come here for the hard ones... I thought you had an htaccess area, but could not find it..

<quote>
Why cant you just go
Thanks for the php offer of help, but problem is this decision has to be made before we get to see any php.
AS you can see here we have yet to know which directory we are being sent..
hxxp://www.mydomain.com/vabe_forcl_13a_id_100005
RewriteRule ^(.*)$ /adwords/?id=$1

The htaccess will determine that I am to goto /adwords... so all decisions have to be made before php exists...

Thanks again Bompa..

Logged
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #6 on: February 26, 2010, 05:27:39 PM »

k let me try again... thanks Bompa for the solution, thanks Perkiset for the L but I am aware of it and use it all the time... Both you folks have given me super advice in the past couple of years..
Matter of fact I am eaten up with [L] stuff.. coming out my ears..see below

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^_id_
RewriteRule ^(.*)$ /adwords/?id=$1 [L]
ReWriteRule index.htm /index.php [L]
ReWriteRule links\/part /work1/work.php [L]
ReWriteRule real-estate /work2/work.php [L]
ReWriteRule buy_sell_ /work3/work.php [L]
ReWriteRule florida_real_ /work3/work.php [L]
ReWriteRule Best_Realtors_ /work4/work.php [L]
ReWriteRule buy-sell-rent /tommy/work.php [L]

This sucker is controlling a wild ass cloaker system and you can see the two lines you gave me in place above, and they are used to allow me to provide a unique landing page for 20,000 real estate keywords with a clean new and unique landing page for every single google ad keyword..and not one page physically exists except in a data base.
Pages built on the fly for google adwords but not cloaking as human and bot see same identical page...

This allows the landing page url to appear to come in to a unique directory on each url but in fact all landing pages are constructed on the fly and its all done in a directory called /adwords of which google knows nothing about.. they think all 20,000 pages exist in the root as the appear below.

Here is the incoming URL: thousands in this format
hxxp://www.mydomain.com/ches_forcl_13a_id_100003
hxxp://www.mydomain.com/norf_forcl_13a_id_100004
hxxp://www.mydomain.com/vabe_forcl_13a_id_100005

Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #7 on: February 26, 2010, 10:02:10 PM »



RewriteCond %{REQUEST_URI} ^_id_
RewriteRule ^(.*)$ /adwords/?id=$1 [L]

I am surprised this is working for you cuz that says the request uri must begin with _id_

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: February 26, 2010, 10:26:53 PM »

Trust the words of Bomps.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #9 on: September 07, 2010, 06:53:44 AM »

Late to the party, but your rewriterules are out of order too. You have to always go from least complex to most complex.
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!