知道为什么这个 mod_rewrite 规则不匹配吗,我认为应该是
我的 ubuntu localhost mod_rewrite 表现得很奇怪。 将网址:
mydomain.com/random/50/post-title-here/
重写为:
mydomain.com/random.php?
我正在尝试使用重写规则
Options -MultiViews
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^random/([0-9]+)$ random.php?id=$1
id=50:我一生都做不到看看这个简单的规则如何匹配错误,但它只是不起作用,正如您从我清理并在此处呈现的重写日志中看到的那样。
RewriteCond: input='www.mydomain.com' pattern='^mydomain\.com$' [NC] => not-matched
127.0.0.1 - - [11/Oct/2011:11:12:44 --0500] [www.mydomain.com/sid#b7a4fc90][rid#b7c0f340/initial/redir#1] (1) [perdir /var/www/] pass through /var/www/rewrite.php
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^random/([0-9]+)$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^link([^/]*).html$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^(.*)$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
RewriteCond: input='mydomain.com' pattern='^mydomain\.com$' [NC] => matched
rewrite 'random/7960/we-serve-up-phat-beets-at-my-house/' -> 'http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/'
explicitly forcing redirect with http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/
trying to replace prefix /var/www/ with /
escaping http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/ for redirect
redirect to http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/ [REDIRECT/301]
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^random/([0-9]+)$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^link([^/]*).html$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^(.*)$' to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
RewriteCond: input='www.mydomain.com' pattern='^mydomain\.com$' [NC] => not-matched
pass through /var/www/random
有什么想法吗?
My ubuntu localhost mod_rewrite is acting funky. I'm trying to rewrite the url:
mydomain.com/random/50/post-title-here/
to:
mydomain.com/random.php?id=50
using the rewrite rule:
Options -MultiViews
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^random/([0-9]+)$ random.php?id=$1
I can't for the life of me see how that simple rule could be matched wrong, but it just isn't working as you can see from the rewrite log that I've cleaned up and presented here.
RewriteCond: input='www.mydomain.com' pattern='^mydomain\.com
Any ideas stack?
[NC] => not-matched
127.0.0.1 - - [11/Oct/2011:11:12:44 --0500] [www.mydomain.com/sid#b7a4fc90][rid#b7c0f340/initial/redir#1] (1) [perdir /var/www/] pass through /var/www/rewrite.php
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^random/([0-9]+)
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^link([^/]*).html
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^(.*)
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
RewriteCond: input='mydomain.com' pattern='^mydomain\.com
Any ideas stack?
[NC] => matched
rewrite 'random/7960/we-serve-up-phat-beets-at-my-house/' -> 'http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/'
explicitly forcing redirect with http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/
trying to replace prefix /var/www/ with /
escaping http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/ for redirect
redirect to http://www.mydomain.com/random/7960/we-serve-up-phat-beets-at-my-house/ [REDIRECT/301]
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^random/([0-9]+)
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^link([^/]*).html
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
add path info postfix: /var/www/random -> /var/www/random/7960/we-serve-up-phat-beets-at-my-house/
strip per-dir prefix: /var/www/random/7960/we-serve-up-phat-beets-at-my-house/ -> random/7960/we-serve-up-phat-beets-at-my-house/
applying pattern '^(.*)
Any ideas stack?
to uri 'random/7960/we-serve-up-phat-beets-at-my-house/'
RewriteCond: input='www.mydomain.com' pattern='^mydomain\.com
Any ideas stack?
[NC] => not-matched
pass through /var/www/random
Any ideas stack?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$
元字符的意思是“断言主题结束”,因此除非数字后面没有任何其他内容,否则您的 URL 将不会匹配。The
$
meta-character means "assert end of subject", so your URL will not match unless it doesn't have anything else after the digits.