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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Htaccess to Run a Script, Then Redirect? 1

Status
Not open for further replies.

tyhand

Programmer
Jul 3, 2002
186
US
Hi all,

Don't know if this is possible but... is there a way to have an HTACCESS File run a javascript code and then redirect to a new page afterwards.

Basically, I'd like to have my htaccess file read and run a snippet of code on a javascript file, if possible. Then afterwards, to redirect visitor to a desired page.

Is this possible?

If not, is there a way I can use an htaccess file to track a visitor, place a cookie on his machine for tracking purposes and then redirect him to another page?

Please feel free to provide any helpful tips, tricks, advice, insights and feedback.

Thanks and Happy New Year!

- Tyhand

 
Couldn't you use rewrite in .htaccess to redirect the user to an interim page which THEN redirects to the destination?

I don't think .htaccess can run things itself, but it doesn't sound like you need that?!

D.E.R. Management - IT Project Management Consulting
 
Hey thedaver,

Thanks for the help.

You mean like mod rewrite? Can you give me a practical example? I'm no expert on it.

For some reason, I was just thinking an htaccess file could maybe call or refer to a javascript.

Thanks again.

- Tyhand
 
the first google match on "mod_rewrite redirect" found this page

The logic you could use:

.htaccess (file)

Rewrite on
RewriteRule ^entry\.php$ tracker.php


then tracker.php does your javascript whatever and then does it's own redirect to the desination page.


I presume you are aware that setting cookies to track users does not require .htaccess files, but can (should) be done by apache itself or as special code within ALL your site's pages?

D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top