这不需要太多解释,很简单,以下是如何工作的:
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]