Is there anyway to make decisions in Htaccess.

T

tommytx

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

Billy Bob

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

Danny

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
 
B

Billy Bob

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top