用htaccess重写规则。 (点)

时间:2014-02-16 17:55:31

标签: apache .htaccess mod-rewrite url-rewriting

嗨,这是我第一次在stackoverflow中很高兴见到你们:) 我有我的.htaccess文件

RewriteRule ^folder/([^/.]+)(/?)$ page.php?x=$1 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2&z=$3 [L]

一起使用
http://localhost/test/folder/hello/001/

http://localhost/test/folder/hello/001/1/

但是。 (点)不起作用

http://localhost/test/folder/hello/001.1/

我该怎么做并思考

2 个答案:

答案 0 :(得分:3)

从负面角色类中删除点:

# skip rewriting for valid files/directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^folder/([^/]+)/?$ page.php?x=$1 [L]
RewriteRule ^folder/([^/]+)/([^/]+)/?$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/]+)/([^/]+)/([^/]+)/?$ page.php?x=$1&y=$2&z=$3 [L]

PS:您需要先在此处规则跳过重写有效文件/目录

答案 1 :(得分:0)

RewriteRule ^folder/([^/.]+)(/?)$ page.php?x=$1 [L]
RewriteRule ^folder/([^/.]+)/([^/]+)(/?)$ page.php?x=$1&y=$2 [L]
RewriteRule ^folder/([^/.]+)/([^/.]+)/([^/.]+)(/?)$ page.php?x=$1&y=$2&z=$3 [L]