我有一个rewriterule适用于除lib文件夹之外的所有内容。规则是
RewriteRule ^ / uk(。*)$ 1
这是一套更复杂的规则之一,但除了这一条之外,我已经禁用了所有规则。 除了lib文件夹的内容之外,该规则适用于所有内容:
http://site.local/lib/cookies.js有效但http://site.local/uk/lib/cookies.js没有。
网站上的其他每条路径都重定向很好,例如:
http://site.local/uk/course/view.php?id=15转到http://site.local/course/view.php?id=15
我错过了什么?!? HELP !!!!!!!!!
---编辑---
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 9
给我
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e1b270/initial] (2) init rewrite engine with requested uri /uk/lib/cookies.js
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e1b270/initial] (3) applying pattern '^/uk(.*)' to uri '/uk/lib/cookies.js'
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e1b270/initial] (2) rewrite '/uk/lib/cookies.js' -> '/lib/cookies.js'
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e1b270/initial] (2) local path result: /lib/cookies.js
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e1b270/initial] (1) go-ahead with /lib/cookies.js [OK]
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e232b0/initial] (2) init rewrite engine with requested uri /favicon.ico
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e232b0/initial] (3) applying pattern '^/uk(.*)' to uri '/favicon.ico'
127.0.0.1 - - [22/Sep/2011:11:21:57 +0100] [site.local/sid#7f15a0b345d0][rid#7f15a0e232b0/initial] (1) pass through /favicon.ico
所以在我看来这应该有用吗?
答案 0 :(得分:1)
我建议启用RewriteLog并增加RewriteLogLevel以获取有关Apache正在做什么的更多信息。
答案 1 :(得分:1)
在我的本地计算机上弄乱了这个之后,在检查document_root / lib目录之前,似乎Apache正在重写文件系统上的/ lib。
您应该将重写更改为:
RewriteRule ^/uk(.*) %{DOCUMENT_ROOT}$1