Page 1 of 1

Fowarding file extension

Posted: Mon Jul 16, 2007 11:20 am
by tecktalkcm0391
[s]Can someone show me how to do this for mod_rewrite. [/s](I still can't understand mod_rewrite :()

[s]A user goes to http://site.com/code.do
If code.do does not exist, open code.php, but shows code.do[/s]

Edited. I got this far with what I was asking to do...

if a user goes to site.com/code.do and there is not a file named code.do or a directory it will open code.php:

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)\.do $1\.php [L]
Now I want to make it so if a user goes to site.com/code.php it redirects them to site.com/code.do if there is no code.do existing already. Can you help me with this. :D