Forum Moderators: phranque

Message Too Old, No Replies

Look Back Feature with PHP

Look Back Feature with PHP

         

hhlost

11:02 pm on Sep 15, 2004 (gmt 0)

10+ Year Member



I'm working on a simple site in PHP. Here's the setup:

+-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

hhlost

11:03 pm on Sep 15, 2004 (gmt 0)

10+ Year Member



oops... turning on email notification...

jdMorgan

11:23 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

JAB Creations

9:32 am on Sep 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Kinda an apache newb here but I'm going to try and make a suggestion regardless...

Why not just set 301?

hhlost

9:52 pm on Sep 17, 2004 (gmt 0)

10+ Year Member



Thanks for the tips guys...

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