问题原文
原帖链接 · Mantykora 7 · CC BY-SA 4.0
I can't use link with *
Example - http://localhost/photo_gallery/public/show_c.html/color-1* The requested URL was not found on this server.
The others work's color-3, wood, etc.
generated map -
map.txttitle id color-1* 1 color-1** 2 color-3 3 wood 4 color777 5 color-test 6htaccess
RewriteRule ^show_c.html/([-\w]+)$ show_c.php?cat=${catcolors:$1} [L]httpd.conf
RewriteMap catcolors "txt:C:\wamp\www\photo_gallery\public\maps\map.txt"
My question. Why the link with * cannot be used.
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
RewriteRule ^show_c.html/([-\w]+)$ show_c.php?cat=${catcolors:$1} [L]
The regex [-\w]+ does not match *, so the pattern never matches the requested URL-path and the value is never looked up in the rewrite map.
Try the following instead:
RewriteRule ^show_c\.html/([-*\w]+)$ show_c.php?cat=${catcolors:$1} [L]
The literal * does not need to be backslash escaped in the regex character class as it carries no special meaning here. (But remember to backslash escape literal dots in other parts of the regex.)
Specifically, the regex [-*\w]+ matches 1 or more of the following:
- (hyphen), * (asterisk), a-z, A-Z, 0-9 and _ (underscore)
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
