Ad

Apache Mod_rewrite To Force Index.php

- 1 answer

im pulling my hair out.

im utilising mod_rewrite to run through index.php if %{REQUEST_URI} isnt an existing document:

#Any request (page) which doesnt exist (item pages, special urls, categories etc)
#get routed through urlparse, where PHP takes over nicely
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.*) urlparse.php?url=$1 [L]

taking this into account, i want a rule BEFORE this one which stipulates:

if %{REQUEST_URI} is empty then pretend it is index.php

my understanding is for a url like

http://www.server.com/

then %{REQUEST_URI} is "" (an empty string), verses

http://www.server.com/something/whatever

where %{REQUEST_URI} is "something/whatever".

thanks for any help you guys can give.

Ad

Answer

Simply:

RewriteRule ^$ index.php
Ad
source: stackoverflow.com
Ad