Forum Moderators: phranque
+-modules/
¦--mod1.php
¦--mod2.php
¦--mod3.php
- index.php
- mod.php
mod.php loads the module specified in the URL. Using apache's lookback feature, the URL to load mod1 is:
mysite.com/mod/mod1
This works perfectly.
What I want to do is to shorten the URL to:
mysite.com/mod1
I've tried making mod1.php a symbolic link to mod.php. It works on my local machine but not on my host's server. Any ideas?
Thanks!
~hhlost
Welcome to WebmasterWorld!
You can try using mod_rewrite to internally rewrite the short URL to the longer one.
Beware of some common problems, though:
Mod_rewrite must be loaded after mod_php so that it runs before mod_php.
Mod_rewrite requires certain settings in AllowOverrides and Options. See this thread [webmasterworld.com].
Jim
I forgot to mention that (for now) the site is on a shared server, so everything has to take place in .htaccess files.
I don't want to do a redirect, because the whole point is to be able to use (and preserve) the nice, cool URIs (http://mysite.com/mod1)
Here's what I've done so far that works, although it's a sloppy solution:
I put files named mod1 mod2 mod3 (no extensions) in the site root with the simple php:
<?php
$module = "modN"; //where N is the # in the filename
include "modules/mod.php";
?>
.htaccess in site root:
ForceType application/x-httpd-php
This worked fine, except that all the other files no longer worked (images, css, js, etc.) so in each sub directory I had to put .htaccess files with this line:
ForceType none
So it's ugly, but it works. Does anyone have a more eloquent solution?
Thanks,
hhlost