IE中的htaccess重写问题 [英] htaccess rewrite problem in IE
问题描述
我正在摆弄.htaccess和mod_rewrite。我有一个网站,有两种类型的URL,我改写了:
I am fiddling around with .htaccess and mod_rewrite. I have a site that has two types of URLs which I rewrote:
-
/index.php?nav=$2
-
/index.php?nav=41&intNewsId=$3
- 41是静态的,新闻导航总是41
/index.php?nav=$2
/index.php?nav=41&intNewsId=$3
-- 41 is static, the news nav is always 41
我把它改写为:
-
/ pagename / id
-
/ news / pagename / id
/pagename/id
/news/pagename/id
我已经制作了一段有效的代码(下图),我得到了社区的一些帮助,但奇怪的是是 http://www.mydomain.nl/projects/15 在FF,Chrome中运行良好和safari,但它在IE中显示页面无法显示。 htaccess在不同的浏览器中的工作方式不同吗? (我非常怀疑)
I already made a piece of code that works (below), I had some help from the community, but the weird thing is that http://www.mydomain.nl/projects/15 works fine in FF, Chrome and safari, but it gives "page cant be displayed" in IE. Does htaccess work differently in different browsers? (I highly doubt it)
Options +FollowSymlinks
RewriteEngine on
# Reroute rules that end on /
RewriteRule ^(.*)\/(\d+) /$1/$2/ [R]
# RewriteRule ^(.*)\/(.*)\/(\d+) /$1/$2/$3/ [R]
# Make the system understand pagename/96
RewriteRule ^(.*)\/(\d+)/ /index.php?nav=$2
# Make the system understand news/pagename/99
RewriteRule ^(.*)\/(.*)\/(\d+)/ /index.php?nav=41&intNewsId=$3
我解决了问题,但我不确定为什么这样做,以前的代码没有。我修复了两件事:我删除了起始/来自/index.php ......没有解决它,但它的字节数更少:D
I solved the problem, but Im unsure why this does work, and the previous code doesnt. I fixed two things: I removed the starting / from /index.php... That didnt solve it, but it's less bytes :D
然后我重写了/ - 重新路由规则,这固定了...
Then I rewrote the /-rerouting rule, this fixed it...
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mydomain.nl/$1/ [L,R=301]
RewriteRule ^(.*)\/(\d+)/ index.php?nav=$2
RewriteRule ^(.*)\/(.*)\/(\d+)/ index.php?nav=41&intNewsId=$3
全部谢谢!
推荐答案
我解决了这个问题,但我不确定为什么这样做有效,以前的代码没有。我修复了两件事:我删除了起始/来自/index.php ......没有解决它,但它的字节数更少:D
I solved the problem, but Im unsure why this does work, and the previous code doesnt. I fixed two things: I removed the starting / from /index.php... That didnt solve it, but it's less bytes :D
然后我重写了/ - 重新路由规则,这固定了...
Then I rewrote the /-rerouting rule, this fixed it...
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mydomain.nl/$1/ [L,R=301]
RewriteRule ^(.*)\/(\d+)/ index.php?nav=$2
RewriteRule ^(.*)\/(.*)\/(\d+)/ index.php?nav=41&intNewsId=$3
这篇关于IE中的htaccess重写问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!