1
<Directory /var/www/html/>
        Options +SymLinksIfOwnerMatch
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?url=$1 [L]
</Directory>

How can I modify the above .htaccess rule to add a / after the URL but without mucking up the existing RewriteRule?

I tried simply appending: RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301] but this did not work.

Stephan Muller
  • 27,018
  • 16
  • 85
  • 126
jskidd3
  • 4,609
  • 15
  • 63
  • 127

1 Answers1

1

Just do a check if the URI ends with a /, and if not add one to whatever the URI was.

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 
Stephan Muller
  • 27,018
  • 16
  • 85
  • 126