我在.htaccess文件中有以下代码
Options +FollowSymLinks
RewriteEngine on
RewriteRule tricks tricks.php?show=all [NC,L]
RewriteRule tricks/ tricks.php?show=all [NC,L]
我不知道为什么我的页面加载了两次
答案 0 :(得分:1)
尝试将以下内容添加到您网站根目录中的htaccess文件中。
它将阻止您的示例中出现循环
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
#if not an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#if not already tricks.php
RewriteCond %{REQUEST_URI} !tricks\.php$ [NC]
#rewrite to tricks.php
RewriteRule ^tricks/?$ tricks.php?show=all [NC,L]
好吧现在正在工作请给我更多重写规则这个技巧/ 13将视为tricks.php?show = one& tid = 12和tricks / ec将trat as tricks.php?show = frmsec& sec = ec
您可以使用下面的解决方案替换上述解决方案,其中包括您的其他要求。
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
#if an existing file or directory
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
#do nothing
RewriteRule ^ - [L]
RewriteRule ^tricks/ec$ tricks.php?show=frmsec&sec=ec [NC,L]
RewriteRule ^tricks/13$ tricks.php?show=one&tid=12 [NC,L]
RewriteRule ^tricks/?$ tricks.php?show=all [NC,L]
答案 1 :(得分:0)
检查HTML中的所有图片“src =”。如果您的某个图片不存在,浏览器将重新加载该页面两次。