Address with and without slash

New to mod_rewrite? This is a good place to start.

Address with and without slash

Postby kuksx » Fri Aug 14, 2009 10:17 am

Hello,

I´m a newbie in using mod_rewrite. I just use it for rewriting site.tld/page to site.tld/index.php?document=page ... simple

But I have problems with ending slash, so when somebody try to go to site.tld/page/ it shows error. I´ve tried many examples I had seen, but anyone works ... And Im also trying to redirect dynamic addresses to static ones ... also no success... could you help me, please?

my .htaccess looks like this:

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([-a-z0-9_]+)/?$ %{DOCUMENT_ROOT}/index.php?document=$1 [NC,L]
kuksx
 
Posts: 1
Joined: Wed Aug 12, 2009 1:46 am

Postby richardk » Fri Aug 14, 2009 1:34 pm

The regular expression looks fine to me.

Is there a reason why you have %{DOCUMENT_ROOT}? Does it not work without it?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 31 guests

cron