web-dev-qa-db-fra.com

Problème avec mon sous-domaine avec .htaccess root comme sous-répertoire

Je travaille sur un site faisant en sorte que mon sous-répertoire apparaisse en tant que root, tout comme //example.com/ soit //example.com/subdir, ainsi que pour accéder/charger des fichiers masquant le sous-répertoire. Mon site a ce .htaccess (ci-dessous) et son fonctionnement.

Mon problème est lorsque j'ajoute un sous-domaine tel que //admin.example.com| which is // example.com/subdir/adminmy. Htaccessredirects me to the main domain // example.com`

Options -Indexes
RewriteEngine on
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
Options +SymLinksIfOwnerMatch

RewriteCond %{HTTP_Host} !^example\.com$ [NC]
RewriteRule .* http://example.com/  [L,R=301]
RewriteRule ^$ example/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/example%{REQUEST_URI} -f
RewriteRule .* example/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* example/index.php?rp=$0 [QSA]
2
seventhief

Je pense que vous devrez faire quelque chose dans ce sens:

Options -Indexes
RewriteEngine on
RewriteBase /
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

#Match admin.example.com default page
RewriteCond %{HTTP_Host} ^admin.example.com$ [NC]
RewriteRule ^$ example/admin/index.html [L]

#Match files that exist in example/admin/
RewriteCond %{HTTP_Host} ^admin.example.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}example/admin/%{REQUEST_URI} -f
RewriteRule .* example/admin/$0 [L]

#Match non-exisiting files in example/admin
RewriteCond %{HTTP_Host} !^admin.example.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* example/admin/index.html?rp=$0 [QSA]

#Redirect anything that's not example.com or admin.example.com to example.com
RewriteCond %{HTTP_Host} !^example.com$ [NC]
RewriteCond %{HTTP_Host} !^admin.example.com$ [NC]
RewriteRule .* http://example.com/   [L,R=301]
#Match example.com default page
RewriteRule ^$ example/index.html [L]

#Match files that exist in example/
RewriteCond %{HTTP_Host} ^example.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}example%{REQUEST_URI} -f
RewriteRule .* example/$0 [L]

#Match non-exisiting files in example
RewriteCond %{HTTP_Host} ^example.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* example/index.html?rp=$0 [QSA]
3
Dan