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

all redirections to start page no matter which URL

Status
Not open for further replies.

handling

Programmer
May 11, 2001
2
DE
hi there, maybe this one here is a dumm question, but i need the answer:

I'd like that my site (let's say redirects all requests to (let's say) page.php

but I want to know WHICH url the user typed

e.g.

(note that userrequest have no extension [.php, .html ...], meaning: userrequest is no page at all)

I'd like the following to happen:

1. redirect to page.php

2. in page.php with something like echo $_SERVER['REQUEST_URI'] should "/userrequest" appear

could some one help me
(sorry about my lack of apache knowledge)
joaquin
 
mod_rewrite can handle this for you
Something like this

#enable rewrite engine ( you may also have to do LoadModule)
# LoadModule rewrite_module modules/mod_rewrite.so

RewriteEngine on

# rules
# don't bother if there is nothing after host name
RewriteCond !^$
# rule
# pass the stuff as part of the query string
RewriteRule ^/(.*) /page.php?req=$1

# enable logging
RewriteLog /path/to/logfile

# make it verbose for testing only
# don't leave this on, it will degrade performance and consume disk space
RewritelogLevel 9

find more info at
localhost/manual/mod/mod_rewrite.html

This should get you started
mod_rewrite is the swiss army knife of apache!

Jeb Beasley
\0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top