【发布时间】:2015-01-04 23:34:06
【问题描述】:
我已经成功实现了基本的 facebook like URL:
http://example.com/(username) 内部调用 http://example.com/sites/(username) 使用以下 mod_rewrite 代码:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/sites/
RewriteRule ^([^/]+)/?(.*)$ sites/$1/$2 [NC,L]
请注意,(用户名)文件夹存在于站点文件夹中
上面的工作非常好。但现在我想美化我的其他网址,例如: http://example.com/(username)/Image/2/ 这应该在内部调用 http://example.com/sites/(username)/index.php?type=image&id=2
为此,我在倒数第二行添加了以下代码:
RewriteRule ^([^/]+)/Image/(.*)$ /sites/$1/index.php?type=image&id=$2 [NC,L]
我希望最后的 [L] 将阻止在此之后计算规则。但是从日志中发现它进入了一个无限循环并被截断。
有人能指出我在这里做错了什么吗?
【问题讨论】:
标签: regex apache .htaccess mod-rewrite redirect