.htaccess htaccess浏览器重定向循环

.htaccess htaccess浏览器重定向循环,.htaccess,.htaccess,大家好, 我无法访问。浏览器仍然警告此网页有重定向循环 我找到了更多解决方案,但无法解决: 我试图将*.php重写/重定向到目录sample index.php到/index 我想将url index.php?id=read&num=11233445667重写为/read/11233445667 成功了。但此网页仍有重定向循环: 请帮我修复上面的htaccess。我非常感谢你 您需要放置最后一条规则: <ifModule mod_rewrite.c> ErrorDocument 40

大家好, 我无法访问。浏览器仍然警告此网页有重定向循环 我找到了更多解决方案,但无法解决: 我试图将*.php重写/重定向到目录sample index.php到/index 我想将url index.php?id=read&num=11233445667重写为/read/11233445667

成功了。但此网页仍有重定向循环:


请帮我修复上面的htaccess。我非常感谢你

您需要放置最后一条规则:

<ifModule mod_rewrite.c>
ErrorDocument 404 /notfound.html
RewriteEngine On
Options +FollowSymLinks -Indexes -MultiViews
RewriteBase /

RewriteRule ^(gateway)($|/) - [L]
RewriteRule ^(inc)($|/) - [L]

# make sure it's not a directory or a file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# match out the request URI without the trailing slash
RewriteCond %{REQUEST_URI} ^/([^/]+?)/?$
# and see if it exists
RewriteCond %{DOCUMENT_ROOT}/%1.php -f

RewriteRule ^(.+?)/?$ /$1.php [L]

RewriteCond %{REQUEST_METHOD} !POST [NC]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+?)\.php
RewriteRule ^(.+?)\.php$ /$1 [L,R=301]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index.php\?id=([a-z0-9]+)&num=([a-z0-9]+) [NC]
RewriteRule ^ %1/%2/ [R=301,L,NC]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]

</ifModule>
在下面的顶部附近^inc$|/-[L]

这样它就不会干扰更一般的php扩展规则。您可能还应该向内部重写添加条件:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index.php\?id=([a-z0-9]+)&num=([a-z0-9]+) [NC]
RewriteRule ^ %1/%2/ [R=301,L,NC]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]
致:


亲爱的,我在index.php文件中发现了问题。因为我在会话超时时设置了重定向,所以我用session_destroy替换它,它工作正常。因此,您的解决方案仍然可以正常工作。谢谢您:
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]