Forum Moderators: phranque
Each user can then give their profile a "real name" using any combination of letters, numbers, etc. that is accessed at a URL like http://example.com/profiles/I_made_this%21
Also, for either form, appending ";public" to the profile URL should bring up a special version of the profile.
When I set up the rewrite for the numbers only, it works perfect. When I try to redirect the other form, I get 500 internal server error. :/
Works:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /profiles
RewriteRule ^new$ /profiles/new.php [L]
RewriteRule ^([0-9]+);public$ /profiles/index.v3.php?public&dd=$1 [L]
RewriteRule ^([0-9]+)$ /profiles/index.v3.php?dd=$1 [L]
Breaks:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /profiles
RewriteRule ^new$ /profiles/new.php [L]
RewriteRule ^([0-9]+);public$ /profiles/index.v3.php?public&dd=$1 [L]
RewriteRule ^([0-9]+)$ /profiles/index.v3.php?dd=$1 [L]
RewriteRule ^(.*);public$ /profiles/index.v3.php?public&uri=$1 [L]
RewriteRule ^(.*)$ /profiles/index.v3.php?uri=$1 [L]
Best guess: There's nothing in your code (the last rule, specifically) to stop the rewritten URL from being rewritten again, so you probably have an 'infinite' rewriting loop. Exclude the 'correct' URLs from being re-rewritten by using a negative-match RewriteCond for those URLs.
Jim
maximum number of internal redirects reached. ...
Exactly as predicted. :) So, I modified it as follows:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /profiles
RewriteRule ^new$ /profiles/new.php [L]
RewriteRule ^([0-9]+);public$ /profiles/index.v3.php?public&dd=$1 [L]
RewriteRule ^([0-9]+)$ /profiles/index.v3.php?dd=$1 [L]
RewriteCond %{REQUEST_FILENAME}! -f
RewriteRule ^(.*);public$ /profiles/index.v3.php?public&uri=$1 [L]
RewriteCond %{REQUEST_FILENAME}! -f
RewriteRule ^(.*)$ /profiles/index.v3.php?uri=$1 [L]
Now it works perfectly! Thanks for your help Jim.
I'm not sure why you needed to add an exclusion to the second-to-last rule -- It doesn't look recursive.
For the last rule, may I suggest:
RewriteCond $1 !^profiles/index\.v3\.php$
RewriteRule ^(.*)$ /profiles/index.v3.php?uri=$1 [L]
Jim
What do you think of the approach below where I check for file endings? It seems to be working as I would expect it to. I'm going to forbid the user generated url from containing any of these strings.
RewriteCond $1!\.php$
RewriteCond $1!\.jpg$
RewriteCond $1!\.gif$
RewriteCond $1!\.png$
RewriteCond $1!\.css$
RewriteCond $1!\.js$
RewriteRule ^(.*)$ /profiles/index.v3.php?uri=$1 [L]