0
我的.htaccess文件出現問題。 一切工作正常,直到我做了一些改變(增加了多語言處理):頁面沒有正確重定向 - .htaccess文件問題
前:
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^(index.html)$ http://my-site.pl/ [R=301,L]
我在文件末尾添加:
RewriteCond %{HTTP:Accept-Language} (pl) [NC]
RewriteRule .* index.html [R,L]
RewriteCond %{HTTP:Accept-Language} (en) [NC]
RewriteRule .* index.en.html [R,L]
RewriteCond %{HTTP:Accept-Language} (jp) [NC]
RewriteRule .* index.jp.html [R,L]
我想將所有國家重定向到他們的頁面,僅在我的頁面URL中更改(..):http://my-site.pl/index.(..).html,如上面的代碼所示。
我找不到問題在哪裏。從Firefox瀏覽器
錯誤:
的網頁沒有正確重定向。 Firefox檢測到 服務器正在重定向該地址的請求,其方式 從未完成。
編輯:被重定向到index.html
/
從而導致重定向循環
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^index\.html$/[R=301,L,NC]
RewriteCond %{HTTP:Accept-Language} pl [NC]
RewriteRule ^(?!index\.html$).+$/[NC,R,L]
RewriteCond %{HTTP:Accept-Language} en [NC]
RewriteRule ^/?$ index.en.html [R,L]
RewriteCond %{HTTP:Accept-Language} jp [NC]
RewriteRule ^/?$ index.jp.html [R,L]
ErrorDocument 404 /404.html
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
不幸的是仍然無法正常工作......同樣的錯誤......每次清除緩存時 – Krzysiek
仍然可以看到相同的錯誤。在Firefox和移動電話上的Internet Explorer上測試 – Krzysiek
pl重定向規則有問題。沒有這個,一切正常,但不幸的是,所有頁面都被重定向到en – Krzysiek