Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable DirectoryIndex based on a cookie?

Status
Not open for further replies.

jimoblak

Instructor
Oct 23, 2001
3,620
US
Would there be any way to push a variable DirectoryIndex through .htaccess based on a cookie stored on the client computer?

For example:

I have index.html with plain content and index-alt.html with extra content for a registered user.

Unregistered users without a cookie would receive the default index.html page when accessing
Registered users with a cookie would receive an alternate page (index-alt.html) when accessing the same web address.

My goal is to keep the same URL appearing in the browser's address bar but different content would display in the page. I can do this content switching easily with PHP and putting all content in index.php but I was wondering if the same effect could be achieved with Apache tricks on plain html pages.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Sure:

Code:
if ( isset( $_SESSION[ 'yourvar' ] )
   include( 'basic-index.html' );
else
   include( 'extended-index.html' );

Or you could use redirects.
 
Ooops, this is the apache forum and not the php forum.

I don't think you can without getting into a procedural language. I don't think server side includes can comprehend cookies, but I haven't read up on them lately, that would be my only other recommendation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top