簡體   English   中英

為什么htaccess中的此重寫規則會導致重定向錯誤?

[英]Why is this re-write rule in htaccess causing re-direct error?

我剛剛更改了我網站上的主機,由於某種原因,當我嘗試查看它時,出現“重定向過多”錯誤。 我已經將其縮小為.htaccess文件中的特定規則,但是我不明白為什么該規則在新服務器上不起作用?

這是規則

RewriteRule ^games/([A-Za-z0-9_-\s\.]+)/?$ /index.php?page=games&console=$1 [NC,L]

完整的htaccess文件

Options +FollowSymlinks
RewriteEngine on

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

<IfModule mod_expires.c>
    ExpiresActive on

    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
</IfModule>


ErrorDocument 404 /not-found/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]


RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [NC,L]
RewriteRule ^play/(.+)/?$ /index.php?page=play&console=$1 [NC,L]
#RewriteRule ^games/([A-Za-z0-9_-\s\.]+)/?$ /index.php?page=games&console=$1 [NC,L]

有這種方式:

ErrorDocument 404 /not-found/
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,NE,L]

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^play/(.+)/?$ /index.php?page=play&console=$1 [NC,L,QSA]
#RewriteRule ^games/([\w\s.-]+)/?$ /index.php?page=games&console=$1 [NC,L,QSA]

RewriteRule ^([^/.]+)/?$ index.php?page=$1 [NC,L,QSA]

在測試之前,請確保清除瀏覽器緩存。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM