Forum Moderators: phranque
For instance, I want it so that whenever somebody visits the site, at any page or any directory, they are redirected to a static .php page.
This page will then redirect people to a new page, according to what they're looking for ($_SERVER['REQUESR_URI']).
So, the static .php page has to be excepted from the redirection rule.
Thanks for your help!
You can easily use mod_rewrite to redirect all requests to your php file, but I wouldn't recommend this. First, a redirect is visible to the user, and requires the user's browser to be involved. In the scenario you describe, two redirects would be required, meaning that for every initial request to your server, two additional requests would occur. So, your site's pages, images, everything, will appear to load three times more slowly.
A more usual approach is to internally rewrite these requests to your script, and again, you can use mod_rewrite to do it. With a rewrite, the server simply substitutes a new local URL-path (filename in simple terms) for the one that was requested, and it does so entirely within the context of the current request. Similarly, you can code your php to "include" or "require" the "page" that is being requested, rather than redirecting to it.
If you redirect all pages to one page, and that page's contents change for each request, as in the method you describe, then your search engine results are not going to be good (to put it politely).
Also, if possible, you should rewrite only *page* requests to your script, and avoid rewriting requests for images, external JavaScript files, CSS files, error pages, robots.txt, and /w3c/p3p.xml files. Serving these filetypes with a php script just complicates your script, and makes your server much more inefficient.
Jim
Thanks for the reply :)
I was actually following an article from <a well-known web design site>.
Although this didn't work for me, so I asked to see if there were any alternative ways.
<They are> known for having solutions to problems that are standards-compliant and search-engine friendly etcetera... So can you point me in the direction of any other way I can achieve <this>?
Thanks :)
-tekp
[edited by: jdMorgan at 3:24 pm (utc) on July 27, 2005]
[edit reason] Removed URLs per TOS. [/edit]
Rewriting static URLs to dynamic URLs [google.com] is a well-covered subject here and elsewhere, and can easily bet done with mod_rewrite. A good place to start might be here [webmasterworld.com].
Jim