【发布时间】:2014-10-23 12:17:25
【问题描述】:
<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>
大家好, 我在使用 htaccess 时遇到问题。浏览器仍然警告此网页有重定向循环 我找到了更多解决方案,但我无法修复它:( 我试图重写/重定向 *.php 到目录示例 index.php 到 /index 我想将 url index.php?id=read&num=11233445667 重写为 /read/11233445667
成功了。但仍然“这个网页有一个重定向循环”:(
请帮我修复上面的 htaccess。非常感谢!
【问题讨论】:
标签: .htaccess