2016-10-21 22 views
1

基本上我http://avitel-bg.com/xdocs/MCACC.pdf當我打開與鏈接PDF加www我被重定向到父文件夾

當我打開它,我得到了重定向到xdocs(根)的父文件夾,我無法查看文件。如果我打開與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

'[R = 301,NC]'沒有'L'(AST),因此重寫可以繼續加工和你以後的規則之一可能是撤消什麼example.com - > www.example.com規則di d。 –

+0

當我刪除其他規則時,它不起作用。當我打開 http:// avitel-bg.com/ ** xdocs ** /MCACC.pdf到http:// www .avitel-bg.com/MCACC.pdf時,我只是不知道該如何重定向。以某種方式刪除文件夾.. –

回答

2

問題是與您的重定向的目標,因爲它會將所有非www請求根

如果你想不帶www重定向請求到子文件夾,你的最後一條規則改成這樣:

RewriteEngine on 
      rewritecond %{http_host} ^avitel-bg.com [nc] 
      rewriterule ^(.*)$ http://www.avitel-bg.com/xdocs/$1 [r=301,nc,l] 
相關問題