Rewrite Trailing Slash Issue
Posted
by James Jeffery
on Stack Overflow
See other posts from Stack Overflow
or by James Jeffery
Published on 2010-06-09T10:54:25Z
Indexed on
2010/06/09
11:02 UTC
Read the original article
Hit count: 350
apache
Here is my .htaccess file
Options +FollowSymlinks
RewriteEngine on
ErrorDocument 404 /404.php
RewriteRule ^(\d*)/(.*) /page.php?id=$1&slug=$2
It all works fine. But the moment I type site.com/342/my-page/ (with the trailing slash) I get a 404.
I need the trailing slash as optional. I.e it will redirect to the correct page with or without the slash.
I tried this, but it didn't work
RewriteRule ^(\d*)/(.*)/?$ /page.php?id=$1&slug=$2
Any ideas?
© Stack Overflow or respective owner