Connecting Tech Pros Worldwide Forums | Help | Site Map

Is there anyway to make decisions in Htaccess.

tommytx
Guest
 
Posts: n/a
#1: Nov 23 '05
Is there any capability of decisions in htaccess. I know you can use
[or] in special situations, but I need something like:

If a then b etc like in php.

In other words I want to redirect the visitor to one of many pages via
the htaccess file.

Is there anyway to open a file and have a redirect to a different web
page based on an input from a text file as below:

Open file and make a random selection from a large number .htm files
and append it to the RewriteRule below.

The below entries may be in a text file.
*******************************************
miami-real-estate.htm
dade-real-estate.htm
charlotte-real-estate.htm
pensacola-real-estate.htm
richmond-real-estate.htm
jersey-real-estate.htm

I need to put the random selection in a variable like $var then append
it to the Rewrite Rule below.

************************************************** ********
RewriteRule happy http://www.othersite.com/$var
************************************************** ********

Bottom line is I want to redirect each arriving user to a different web
page each time someone arrives with the word happy in the URL.

Thanks in advance.


MsKitty
Guest
 
Posts: n/a
#2: Nov 23 '05

re: Is there anyway to make decisions in Htaccess.


Sounds like something that would be easiest to do with PHP. So you
would create http://www.othersite.com/startpage.php(or whatever) and
it would randomly pick a page from its array when the incoming url has
happy in it and use the header statement to redirect to that page.
Kitty
http://www.openskywebdesign.com

Billy Bob
Guest
 
Posts: n/a
#3: Nov 23 '05

re: Is there anyway to make decisions in Htaccess.






*** Sent via Developersdex http://www.developersdex.com ***
Billy Bob
Guest
 
Posts: n/a
#4: Nov 23 '05

re: Is there anyway to make decisions in Htaccess.


Thanks for the quick response mskitty, but I am trying to redirect a
spider, and I realize I could use the htaccess file to redirect the
spider to the php file and then forward them to any random page, but I
have had no luck with the php Header ("Location: http://newsite.com");
It will redirect the real people, but spiders seem to ignore it just as
they do of course in the javascript forwarding scenario.
Is it possible to redirect the spider with the Location: command. I know
they can be fed a new page with the include command, but I need to send
them to a new site.

Bottom line can I redirect a spider with the Location command? Or do
they just ignore it.







*** Sent via Developersdex http://www.developersdex.com ***
Danny
Guest
 
Posts: n/a
#5: Nov 23 '05

re: Is there anyway to make decisions in Htaccess.



I agree with MsKitty, have PHP do it, not the webserver. And yes, Apache
does have <if...> statements, but for this task, PHP will be optimal.


Danny
Billy Bob
Guest
 
Posts: n/a
#6: Nov 23 '05

re: Is there anyway to make decisions in Htaccess.


Thanks Danny, but do you agree the spiders ignore the optimal php
command in the header for Location: or am I on the wrong track and
spiders will follow Location:
Since you didn't offer any suggestions as to where I could find <if> I
will go to the apache htaccess section and search the manual for if
statements. Thanks again.





*** Sent via Developersdex http://www.developersdex.com ***
Closed Thread