mod rewrite tip: trailing slash in directory rewrites

Discussion in 'Apache' started by phpl33t, Jan 24, 2008.

  1. #1
    Having problems with accessing your seo friendly urls when you remove the trailing slash from them?

    
    
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !\.
    RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
    
    
    Code (markup):
    There is the cure, will require trailing slashes and rewrite the url if the user forgets to include it.

    Example"

    
    
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !\.
    RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
    RewriteRule (.*)/(.*)/$ /page.php?$1=$2
    
    
    Code (markup):
     
    phpl33t, Jan 24, 2008 IP