Load URL regardless of if a trailing / is present

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 20 Nov 2012, 16:17

Load URL regardless of if a trailing / is present

20 Nov 2012, 16:20

Hello,
Here is my rewrite code:
Code: Select all
RewriteRule ^free-stuff/[^/]+/(\d+)/$ /link-details.asp?lid=$1 [NC,L,QSA]

if you go to this url it loads:
http://uk.mysavings.com/free-samples/Thorntons/2987/

This url does not:
http://uk.mysavings.com/free-samples/Thorntons/2987

would you mind letting me know what I am doing wrong?

Thanks!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Load URL regardless of if a trailing / is present

21 Nov 2012, 00:02

Hello,

In your code you've specified the '/' at the end, to make it optional we need to add '?' after it:

Code: Select all
RewriteRule ^free-stuff/[^/]+/(\d+)/?$ /link-details.asp?lid=$1 [NC,L,QSA]


Regards
Andrew

User avatar
Posts: 24
Joined: 27 Nov 2012, 21:57

Re: Load URL regardless of if a trailing / is present

01 Dec 2012, 00:38

I lack "?" character almost all the time. This clears everything.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests