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.

1 Answer 1

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] 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.