homepage Welcome to WebmasterWorld Guest from 54.205.122.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Fake Directory Mod_rewrite problem with slashes
Mod_rewrite question
pjmaenh

10+ Year Member



 
Msg#: 894 posted 8:50 pm on Jan 18, 2004 (gmt 0)

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?

 

jdMorgan

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



 
Msg#: 894 posted 10:07 pm on Jan 18, 2004 (gmt 0)

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

mep00

10+ Year Member



 
Msg#: 894 posted 10:54 pm on Jan 18, 2004 (gmt 0)

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.
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved