3 simple htaccess tasks, so why am I looping?

Question!

I am trying to accomplish 3 fairly standard url mods in my htaccess file, but unfortunately I am getting thrown in a loop. What am I doing wrong?

# force a trailing slash
RewriteRule ^profile/([^/]+)$ /profile/$1/ [R=301,L]

# check for trailing parameters
RewriteCond %{QUERY_STRING} ^(.*)$

# put it all together
RewriteRule ^profile/([^/]+)/$ /profile/index.php?username=$1&%1 [NC,L]
By : ggwarpig


Answers

The pattern of your first rule, ^profile/([^/] )$, does also match the destination of your second rule, profile/index.php.

You could simply exclude that file with an additional RewriteCond for the first rule:

RewriteCond $1 !=index.php
RewriteRule ^profile/([^/] )$ /profile/$1/ [R=301,L]
By : Gumbo


This video can help you solving your question :)
By: admin