troubleshooting Question

htaccess rewrite rule - optional trailing slash

Avatar of phillystyle123
phillystyle123Flag for United States of America asked on
PHPApache Web Server
7 Comments4 Solutions1390 ViewsLast Modified:
my client has requested that a URL work regardless of whether or not there is a trailing slash

i've updated my htaccess file and my rewrites are getting this accomplished:

for example this:
and this:
both go to the same page

here's my rewrite rule for that:

RewriteRule ^/current/([^\/\.]+)/?$ /current/index.cfm?PageNum_curreximages=$1 [QSA]

works great.

for some reason my rewrite for this URL is different:

and this:

does not work.

here's my rewrite for that:

RewriteRule ^/new/([^\/\.]+)/?$ /newaq/index.cfm?PageNum_newaqimages=$1 [QSA]
RewriteRule ^/new/(.*) /newaq/$1 [QSA]

it has something to do with this last bit:
RewriteRule ^/new/(.*) /newaq/$1 [QSA] (which i'm not using anywhere else in my htaccess - just for the newaq section.

you'd think if i deleted it and just used this:
RewriteRule ^/new/([^\/\.]+)/?$ /newaq/index.cfm?PageNum_newaqimages=$1 [QSA]

it'd work but it does not.

again - i need both of these urls to resolve to the same page:

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros