Following is the Folder Structure of my PHP Project
PHPProject (Root)
-->Admin/
-->Config/
-->File1.php
-->File2.php
--> ..
--> ..
-->.htaccess
-->File10.php
I would like to enable RewriteURL for the project that can be accessed in the following manner.
Rule 1:
My Domain should always be accessed with www.mydomain.com. If someone tries to access as http://mydomain.com i will have to rewrite the URL to http://www.mydomain.com. For which I am using the following rule on my htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
#RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
</IfModule>
Rule 2: I would like to have a specific URL that points to a page:
http://www.mydomain.com/username to rewrite to http://www.mydomain.com/file4.php?name=username
Rule 3:
I am able to get the first rule to work properly with the above information on .htaccess file, but the problem is I have to hardcode the domain name on it. Would it be possible to specify a generic (regex) so that the rule applies to multiple domain?
Question: I require help to combine Rule 1 + Rule 2 + Rule 3 altogether as rules on my .htaccess file.
Could someone please help me acheive this.