.Htaccess子域扩展无法正常工作

时间:2016-10-20 14:09:43

标签: php apache .htaccess mod-rewrite url-rewriting

我希望以下工作:

<subdomain>.domain.com 

显示以下目录中的内容

/sites/<subdomain>

我必须让它来显示索引(用HTML或PHP),但是如果我继续使用http://.domain.com/test,那么显示test.html或test.php就是一个意思。当下。我没有找到/sites/index.php。

这是我的.HTAccess

Header set X-Frame-Options SAMEORIGIN
Options +FollowSymLinks -Indexes -Multiviews
IndexIgnore *
AddDefaultCharset utf-8
DirectoryIndex index.html index.php
ServerSignature EMail
SetEnv SERVER_ADMIN admin@domain.com
SetEnv CI_ENV development

<FilesMatch ".(htaccess|ini|phps|log|sh)$">
    order deny,allow
    deny from all
</FilesMatch>

<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|json|xml|tpl)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>

ErrorDocument 400 /views/global/error/400.html
ErrorDocument 401 /views/global/error/401.html
ErrorDocument 403 /errors/404
ErrorDocument 404 /errors/404
ErrorDocument 500 /views/global/error/500.html

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule .+ - [L]

RewriteCond %{DOCUMENT_ROOT}/$1\.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteCond %{DOCUMENT_ROOT}/$1\.json -f
RewriteRule ^(.+?)/?$ $1.json [L]

RewriteCond %{DOCUMENT_ROOT}/$1\.tpl -f
RewriteRule ^(.+?)/?$ $1.template [L]

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType application/json "access plus 0 seconds"
</IfModule>

RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$
RewriteRule ^(.*)  %{HTTP_HOST}$1 [C]
RewriteRule ^(.*)\.domain\.com(.*) /sites/$1/$2 [L,NC,QSA]

RewriteCond %{QUERY_STRING} proc/self/environ [OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})

RewriteRule ^(.*)$ index.php [F,L]

RewriteRule ^errors(|/)$ / [R=301,L,NC]
RewriteRule ^errors/(.*)$ /views/global/errors/$1 [L,NC]
RewriteRule ^global/(.*)$ /views/global/$1 [L,NC]
RewriteRule ^(.*)-(.*)/forums(|/)(.*)$ /sites/forums/index.php [L,NC]
RewriteRule ^(.*)-(.*)/templates/(.*)$ /views/templates/$3 [L,NC]
RewriteRule ^(.*)-(.*)/$ /views/index [L,NC]
RewriteRule ^(.*)-(.*)/([^/]+)/([^/.]+)/([^/.]+)/?$ /views/$1/$2/$3_$4_$5 [L,NC]
RewriteRule ^(.*)-(.*)/([^/]+)/([^/.]+)/?$ /views/$3_$4 [L,NC]
RewriteRule ^(.*)-(.*)/([^/]+)?$ /views/$3 [L,NC]

错误日志显示以下内容:

[Thu Oct 20 14:33:24.679400 2016] [:error] [pid 8076:tid 1872] [client 141.101.99.135:31179] script 'C:/xampp/htdocs/sites/index.php' not found or unable to stat
[Thu Oct 20 14:33:24.682401 2016] [:error] [pid 8076:tid 1872] [client 141.101.99.135:31179] script 'C:/xampp/htdocs/sites/index.php' not found or unable to stat

0 个答案:

没有答案