Forum Moderators: phranque
RewriteRule ^group/([^/]+)$ group.php?gid=$1 [L,QSA] htp://mydomain.com/group/group-name/
htp://mydomain.com/group/group-name http://mydomain/nickname
http://mydomain/group/group-name RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [NC]
RewriteRule ^([a-z0-9-]+)\/?$ profile.php?nick=$1 [QSA,L]
RewriteRule ^group/([^/]+)$ group.php?gid=$1 [L,QSA]
http://www.mydomain.com/username RewriteRule ^([^/.]+)$ profile.php?nick=$1 [L,QSA] http://www.mydomain.com/directory_name (without trailing slash) http://www.mydomain.com/directory_name/?nick=directory_name Do you have a particular reason for using {SCRIPT_FILENAME} instead of the more common {REQUEST_URI}?
RewriteCond %{REQUEST_URI} !-d, the URL rewrites to http://www.modomain.com/nick even if directory exists. Open folders by using a URL that has a trailing slash.
Investigate the DirectorySlash directive. Does it fix up folder URLs before your rewrite has a chance to operate on the incoming request?
http://www.mydomain.com/directory_name/?nick=directory_name Remember too that a RewriteCond affects only the single RewriteRule that it precedes.
RewriteCond %{SCRIPT_FILENAME} !-d
First rule
RewriteCond %{SCRIPT_FILENAME} !-d
Second rule
I don't use DirectorySlash. As I know it causes other problems and I don't understand how can it help to avoid rewrites like : http://www.example.com/directory_name/?nick=directory_name
does it mean that if I need 2 rules with the same condition, the .htaccess file should look like this?
<snip>
You don't use DirectorySlash.
Or swap things around so you have a string of [OR] conditions feeding into a single Rule.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9-]+)\/?$ profile.php?nick=$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)$ profile.php?nick=$1 [L,QSA] http://www.mydomain.com/directory_name/?nick=directory_name http://www.mydomain.com/directory_name http://www.mydomain.com/directory_name/?nick=directory_name RewriteRule ^([^/.]+)$ profile.php?nick=$1 [L,QSA] RewriteRule ^([^/.]+)$ /profile.php?nick=$1 [L,QSA] When the target is /$1-something (with a backrefence at the beginning) omitting the leading slash leaves your site wide open to hackers.
Beware that a target of $1.php allows the user to inject whatever path information they want. You must use /$1.php with a leading slash to mitigate this security risk.