2

这不需要太多解释,很简单,以下是如何工作的:

RewriteRule ^errors/browser/?$ /_errors/browser.php?error=browser [NC,QSA,L]

这不起作用:

RewriteRule ^error/browser/?$ /_errors/browser.php?error=browser [NC,QSA,L]

上面两个片段的唯一区别是s从单词末尾删除了字母error

我不明白为什么在s单词上添加一个error突然使该代码起作用。我能想到的唯一解释error是保留字?是这样吗?

如果是这种情况,那么我如何error使用.htaccess文件匹配和重写单词?

更新

这是我的整个.htaccess文件:

# Define the default document
DirectoryIndex index.php

# Turn on the rewrite engine
RewriteEngine On

# Compress all HTML, Javascript, CSS, XML... files
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

# Set the error page rewrites
RewriteRule ^errors/browser/?$ /_errors/browser.php?error=browser [NC,QSA,L]

# Set the general first level rewrites
RewriteRule ^([a-z-]+)\/?$ $1.php? [NC,QSA,L]
RewriteRule ^([a-z-]+)\/([a-z-0-9]+)\/?$ $1.php?id=$2& [NC,QSA,L]
4

1 回答 1

1

很奇怪 vim 会突出显示“错误”这个词,但你可以简单地尝试这个来破解它:

RewriteEngine On
RewriteRule ^erro[r]/index.html [NC,QSA,L]

这是一个可能相关的问题:question-10872503

于 2012-12-06T11:00:53.157 回答