Reputation: 79
Here is the htaccess in the public_html:
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
Options -Multiviews
Options -Indexes
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{REQUEST_URI} !api\\dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.* api/dispatch.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Here is the code for the htaccess in public_html/sites/
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks -MultiViews
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^/.]+)\.webznap\.com$ [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteCond %{REQUEST_URI} !^/sites [NC]
RewriteRule ^ http://webznap.com/sites/%1/ [L]
Here is the htaccess for public_html/sites/luis/
RewriteEngine On
ErrorDocument 400 /page/error
ErrorDocument 401 /page/error
ErrorDocument 403 /page/error
ErrorDocument 404 /page/error
ErrorDocument 500 /page/error
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
There you go thank you for all your help prix i really appreciate it !
Upvotes: 2
Views: 166
Reputation: 19528
Give this a try:
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options -Multiviews -Indexes +SymLinksIfOwnerMatch
RewriteEngine on
ErrorDocument 400 /page/error
ErrorDocument 401 /page/error
ErrorDocument 403 /page/error
ErrorDocument 404 /page/error
ErrorDocument 500 /page/error
RewriteCond %{HTTP_HOST} ^([^/.]+)\.webznap\.com$ [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteCond %{REQUEST_URI} !^/sites [NC]
RewriteRule ^ /sites/%1%{REQUEST_URI} [L]
RewriteCond %{REQUEST_URI} !api\\dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.* api/dispatch.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
SIDE NOTE: public_html/sites/.htaccess
and public_html/sites/dynamic_subdoamin/.htaccess
should be removed!
And make sure that:
anything_you_try.domain.com
Exists on:
anything_your_try.domain.com/sites/anything_your_try
Or it will fail.
What it does?
The first line catch the sub-domain name if any:
RewriteCond %{HTTP_HOST} ^([^/.]+)\.example\.com$ [NC]
This line makes sure the sub-domain is not www, ftp or mail:
RewriteCond %1 !^(www|ftp|mail)$ [NC]
This line verify is the URL path does not start with /sites
:
RewriteCond %{REQUEST_URI} !^/sites [NC]
This line will internally redirect whatever the URL is:
RewriteRule ^ /sites/%1%{REQUEST_URI} [L]
So if the URL was for example:
http://luis.domain.com/hello
It will show the content of:
http://luis.domain.com/sites/luis/hello
Without changing the URL.
Upvotes: 3