user628625
user628625

Reputation: 1

HTACCESS Rewrite Help - SEO Trailing Slash

My Working URL: http://www.mydomain.com/user/

Broken URL: http://www.mydomain.com/user

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ /lookup.asp?q=$1 [NC,L]

How can I modify my current code so that the url works with or without a trailing slash?

Thanks in advance.

Upvotes: 0

Views: 468

Answers (1)

Floern
Floern

Reputation: 33904

You have to add just a ? to your RegEx, to make the / optional:

RewriteRule ^([^/]+)/?$ /lookup.asp?q=$1 [NC,L]

In this way, both URLs are working.

Or you could just remove the slash.

Upvotes: 1

Related Questions