Hello people, it's been awhile!
I had to enable userdir in my server for users to host their own pages in the form of "http://example.mysite.gr/~user
I wanted to do that by using mod_rewrite and not by enabling the userdir module brought by Apache so I ended up writing this rewrite down in my .htaccess file.
Options +FollowSymLinks
RewriteEngine On
/*The folder the userfiles reside inside my document root
RewriteRule ^(webteam) - [L]
/*Rewriting starts here
RewriteCond %{HTTP_HOST} ^example.mysite.gr$
/*When this conditions are met
RewriteCond %{REQUEST_URI} !^/~\w+/.*$
/*Then point to this folder inside webteam folder where $1 is the user's name and $2 is index.html
RewriteRule /~(\w+)/(.*) /webteam/$1/public_html/$2
RewriteCond %{REQUEST_URI} !^/~\w+$
RewriteRule /~(\w+) /webteam/$1/public_html/
/*In the beggining if client doesn't choose to enter userdir mode then point to a subfolder named static and hide url formation
RewriteCond %{REQUEST_URI} !^/static/
RewriteRule (.*) /static/$
----
So far this works smoothly but for one problem.
mod_rewrite userdir works but only for index.html - if index page of user has a link in another page inside his site then it forgots all about rewrite and it points to a file which supposedly resides in example.mysite.gr/static/
To make things clearer:
A siteuser wants to enter http://example.mysite.gr/~user1
This is done correctly - the rewrite works and points to
http://example.mysite.gr/webteam/user1/public_html/index.html
When siteuser click on a link in the user1's index page for instance:
http://example.mysite.gr/webteam/user1/public_htm/secondpage.htm
then rewrite malfunctions and it searches secondpage inside http://example.mysite.gr/static/
Could we set this right?