Forum Moderators: phranque
Leave these URL's alone:
[mysite.com...]
[mysite.com...]
[mysite.com...]
[mysite.com...]
[mysite.com...]
But if the user types in:
[mysite.com...]
to convert the username into a url like
[mysite.com...]
I am willing to change the addphoto profile to have a dot extension. To say what I want in english is:
any URL without an extension (.something) or a subdirectory to get mapped to the profile.php page?
I've used this Rewrite rule but would like to get rid of the ~
RewriteRule ^/~([^/]+)/?(.*) /profile.php?uid=$1 [R]
RewriteRule ^/([uge])/([^/]+)$ /$1/$2/ [R]
Thanks
Andy
Welcome to WebmasterWorld!
There are too many ambiguities here to present a solution, but a few example RewriteConds mays demonstrate a way forward:
# Suppress rewrite if "home page" request
RewriteCond %{REQUEST_URI} !^/?$
# Suppress rewrite if additional "/" or any "." in URL (excludes all subdirectories and .html, .php, .gif files, etc.)
RewriteCond %{REQUEST_URI} !^/.+(/¦\.)
# Forward usernames to script (usernames must be alphanumeric, undescore or hyphen only)
RewriteRule ^/([a-z0-9_\-]+)/?$ /profile.php?uid=$1 [NC,L]
The usernames have been restricted to a known reduced character set to prevent future naming conflicts and problems with php calling parameter syntax. For example, this prevents a user trying to sign up as "Best_B&B", which would cause php to think that there were two calling parameters, "Best_B" and "B" because "&" is used as a parameter separator. You should also enforce this same restriction in the "account creation" script.
Change the broken pipe "¦" character above to a solid pipe before use. Posting on this board modifies them.
I have no idea what your last rule is for, so I can't comment much on it. However, if its purpose is to "fix" broken incoming links, then you should use a canonical URL and a 301 redirect:
RewriteRule ^/([uge])/([^/]+)$ http://www.example.com/$1/$2/ [R=301,L]
Because I currently have ~userid convention and % encode the weird characters. I've since stopped those characters for new accounts, but still have a few with % $ & in them. I tinkered with your Rule to the following.
RewriteRule ^/([^\n~]+)/?$ /profile.php?uid=$1 [NC,L]
The way I read this is that it will take any character with the exception of NewLine and ~ and pass it on. When I print the users URL for PHP I convert Spaces to + and & to %26 and so on.
So on their profile page they would see something like this
Direct Link:
[sitename.com...]
That rule seems to work on my test setup but not sure if I'm opening myself to other problems by doing it.
Again Thanks very much.
Andy