views:

604

answers:

2

Hello, I have some mod_rewrite rewrites that correctly redirect the URLs to a script. From within the script, I want to go to a different file without causing another request/changing the URL.

I have experimented with Location and meta refreshes but they are not as smooth as desired.

Is there a way to change to the script or even return data to the rewrite rules so it can be further rewritten?

improfane.domain.com is sent to script which gets user id from database, I then redirect to the profile page with the user ID. I want it to be more smooth, without a redirect. It means that improfane.domain.com would stay in the URL, rather than going to domain.com/?profile=6

Thanks

+1  A: 

You should use a front controller (also referred to as bootstrapping) to determine the route and include the correct script (rather than re-direct). A front controller is a single entry point to your application, and allows you to handle routing as you see fit.

Most frameworks have a nice implementation of a front-controller, but for simple purposes you can roll your own.

Eran Galperin
+3  A: 

You can include the real target file with one of the following php directives:

include(filename)
require(filename)
include_once(filename)
require_once(filename)
Eineki