开发者

Any idea why this mod_rewrite rule isn't matching, I think it should be

开发者 https://www.devze.com 2023-04-12 12:31 出处:网络
My ubuntu localhost mod_rewrite is acting funky.I\'m trying to rewrite the url: mydomain.com/random/50/post-title-here/

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$' [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

Any ideas stack?


The $ meta-character means "assert end of subject", so your URL will not match unless it doesn't have anything else after the digits.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号