Welcome to WebmasterWorld Guest from 54.144.206.214

Forum Moderators: Ocean10000 & incrediBILL & phranque

Fake Directory Mod_rewrite problem with slashes

Mod_rewrite question

   
8:50 pm on Jan 18, 2004 (gmt 0)

10+ Year Member



Hi,

i have this problem:
like most people, i want to get my server so that
[domain.com...]
Goes to [domain.com...]
I tried this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
RewriteRule ^([^/]+)/$ index.php?menu=$1 [L]

This only works fine when I add a / behind item:
[domain.com...] works,
but I want [domain.com...] to work too.
How can I do this?

10:07 pm on Jan 18, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



pjmaenh,

Welcome to WebmasterWorld [webmasterworld.com]!

You can make the trailing slash optional by following it with "?"


RewriteRule ^([^/]+)/?$ index.php?menu=$1 [L]

Ref: Regular Expressions tutorial [etext.lib.virginia.edu].

Jim

10:54 pm on Jan 18, 2004 (gmt 0)

10+ Year Member



There's an easier way:

RewriteRule ^(\.*)$ index.php [L]


index.php:
<?php
$uri = explode("/", $_SYSTEM['REQUEST_URI']);
$menu = $uri[1];
?>

Mind you, I don't have much experience with this, so I might have made an error, but the basic idea is correct.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month