Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Trailing slash issue with multiple parameters

Trailing slash issue

4:38 am on Jun 7, 2010 (gmt 0)

Full Member

10+ Year Member

joined:Aug 22, 2005
posts: 323
votes: 0

Hi All,

I am again stuck with trailing slash issue, this time a little bit complicated.

This is my rewrite:

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^([a-zA-Z_]+)$ index.php?country=$1
RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)$ index.php?country=$1&state=$2
RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)/([a-zA-Z_]+)$ index.php?country=$1&state=$2&city=$3
RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)/([a-zA-Z_]+)/age-([0-9\-]+)$ index.php?country=$1&state=$2&city=$3&age=$4

It works like this.. each time when a user selects country it asks for the state and then city. for example


after that


after that


and so on..

It works fine.. BUT when i add trailing slash, I get page not found error.

For example

domainname.com/country would work perfect


domainname.com/country/ will give error


domainname.com/country/state would work fine



will generate error

Please help me.

6:39 am on June 7, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
votes: 0

First off, you need to add
to each rule.

flag will parse faster than
here. However, I would use a hyphen not an underscore in the URL.

To fix the other problem, you simply need a redirect before all of these rewrites such that if URL is requested with trailing slash, user is redirected to URL without trailing slash.

A search for "
site:webmasterworld.com remove trailing slash
" will find prior examples.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members