0

¦ 符号在 htaccess 中的作用是什么?我从 htaccess 的在线论坛中获取了一个代码,他们使用 ¦。如果可能与管道符号有任何区别,我想了解这个符号在 htaccess 中的含义|

RewriteEngine on
#
### Disallow Image Hotlinking
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.example\.net
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ - [F]
#
### Externally redirect to remove ".php" if the user adds it
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.example.net/$1 [R=301,L]
#
### Externally redirect to remove double slashes
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . http://www.example.net/%1/%2 [R=301,L]
#
### Externally redirect to remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://www.example.net/$1 [R=301,L]
#
### Externally redirect non-canonical hostname requests to canonical
### domain (if not already done by one of the preceding rules)
RewriteCond %{HTTP_HOST} !=www.example.net
RewriteRule ^(.*)$ http://www.example.net/$1 [R=301,L]
#
### Internally rewrite requests for URLs which do not resolve
### to physically-existing files or directories to a PHP file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
4

1 回答 1

1

它当然不应该在那里,并且可能是由于从包含错误符号的来源复制和粘贴而到达那里的。

对于 RegExp 库,它只是另一个没有任何特殊含义的文字字符。它不会被视为管道符号,即类似于书写

RewriteRule \.(jpe?gxgifxbmpxpng)$ - [F]

它会使规则变得无用。

来源:测试它以确保。

于 2013-02-11T00:53:40.647 回答