基本上我得到了http://avitel-bg.com/xdocs/MCACC.pdf
当我打开它时,我被重定向到xdocs(root)的父文件夹,我无法查看该文件。如果我用www(http://www.avitel-bg.com/xdocs/MCACC.pdf)打开链接,我可以正常查看PDF。
这是我的htaccess:
Options +Indexes +FollowSymLinks -MultiViews
RewriteEngine on
rewritecond %{http_host} ^avitel-bg.com/ [nc]
rewriterule ^(.*)$ http://www.avitel-bg.com/$1 [r=301,nc]
# BEGIN products Rewrite
RewriteRule ^(kadmin)(/.*)?$ - [L]
RewriteRule ^(kadmin2)(/.*)?$ - [L]
RewriteRule ^(polycomp)(/.*)?$ - [L]
RewriteRule ^(.*)-cat([0-9]+) categories.php?cid=$2 [L,NC]
RewriteRule ^([A-Za-z0-9-_]+)/?$ products.php?pid=$1 [L]
# END products Rewrite
<IfModule mod_negotiation.c>
ErrorDocument 404 /404.php
</IfModule>
<IfModule mod_geoip.c>
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE (US|CH) DenyCountry
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/x-ico "access plus 1 year"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType text/css "access plus 14 days"
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE img/svg+xml application/xhtml+xml application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index\.php$ / [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
答案 0 :(得分:2)
问题在于您的重定向目标,因为它将所有非www请求重定向到root
如果您想将非www重定向到请求到子文件夹,请将您的上一条规则更改为:
RewriteEngine on
rewritecond %{http_host} ^avitel-bg.com [nc]
rewriterule ^(.*)$ http://www.avitel-bg.com/xdocs/$1 [r=301,nc,l]