I strongly recommend that all PHP developers build their sites with a front controller - i.e., one script that all hits are redirected to. Then that script can read the incoming URL and load the correct pages. To do this, you use a redirect like the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
Then, in index.php, you can get the url with
$url = $_SERVER['REQUEST_URI'];
I have found that this method saves me time even on sites with only a couple pages.
-Rob
At 5/4/08 05:27 PM, yhar wrote:
Hi,
I have "domain.com"
I have "domain.com/file.php"
I want "domain.com/file" to redirect to "domain.com/file.php"
I want this for every file, not just ones i set manually.
I have it atm so i can set them manually, but I want it automatic, adding manually is a pain.
What's the mod_rewrite code?
Much appreciated darlings <3