I’m trying to make a facebook like user profile page using .htaccess
ie. http://example.com/<userid > will actually call http://example.com/sites/<userid >/<sub_page >
using thefollowing code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?(.*)$ sites/$1/$2 [NC,L]
Options -Indexes
ErrorDocument 404 /missing.html
ErrorDocument 403 /forbidden.html
It works perfectly well when the folder sites/<userid> exists but when it doesn’t it throws 500 internal error. I’ve scoured the internet but couldn’t go beyond this. Can someone please help with this.
Can i have a text file with all existing folders and somehow use that to generate a list in the .htaccess?
Thanks in advance!! 🙂
Your rewrite rules are looping. The regular expression
^([^/]+)/?(.*)$is matching the rewritten URIsites/something/somethingand it’s looping indefinitely (so your URI starts looking like:sites/sites/sites/sites/sites/sites/sites/sites/sites/something/somethingetc).Either tweak your regular expression so that it doesn’t liberally match what’s after the first
([^/]+)/?expression or add an additional condition: