Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorbabyben
    • CommentTimeJan 5th 2007
     permalink
    I've currently got a site setup with .htaccess rewrite so that : domain.com/foo/ redirect to domain.com/index.php?id=foo

    All works, but if someone visits domain.com/foo - i.e. without the trailing slash, it all doesn't. I've noticed the SE seem to hack off the '/' sometimes as well.

    I've googled but didn't find a solid answer.. I'm looking for .htaccess code that adds a / to the end of directories - but not files.

    Any ideas?

    (Oh, and hello - first post!)
    • CommentAuthorvarland
    • CommentTimeJan 5th 2007
     permalink

    Try something like:

    RewriteRule ^foo/?$ /index.php?id=foo

    The "?" after the slash means that it may or may not be there.

    • CommentAuthorbabyben
    • CommentTimeJan 5th 2007 edited
     permalink
    Cheers for your reply - just tried this, and it works with domain.com/foo but now doesn't work with domain.com/foo/ so it's went the opposite way!
    • CommentAuthorverb
    • CommentTimeJan 6th 2007 edited
     permalink

    Try something like this:

    RewriteRule ^([a-zA-Z0-9\_\-]+)/$ index.php?id=$1
    RewriteRule ^([a-zA-Z0-9\_\-]+)$ index.php?id=$1
    • CommentAuthorbabyben
    • CommentTimeJan 7th 2007
     permalink
    Just got a minute to try the above out, and works perfectly with slash and no slash - so thank you Maarten! Much appreciated.
Add your comments
    Username Password
  • Format comments as (Help)