0

mod_alias rule:

/water    /local/path1/water

Target URLs:

http://www.mysite.com/water/css/style.css
http://www.mysite.com/water/js/java.js

Actual URLs:

http://www.mysite.com/water/css.php?src=style.css
http://www.mysite.com/water/js.php?src=java.js

Mod rewrite rule:

RewriteEngine on

RewriteCond /local/path1/water%{REQUEST_URI} !-d
RewriteCond /local/path1/water%{REQUEST_URI} !-f
RewriteRule ^/water/css/([^/]+)$ /local/path1/water/css.php?src=$1 [PT] 
RewriteRule ^/water/js/([^/]+)$ /local/path1/water/js.php?src=$1 [PT]

Problem: it's not working and I am getting 404 errors and the error says this script /www/mysite.com/htdocs/css.php not found or unable to start

4

1 回答 1

0

1.我没有太多使用 mod_alias 的经验 .. 但我认为你通过重写做错了/local/path1/water/-- mod_rewrite 进行 URL 重写,所以这里也应该是 URL。

2.我会假设这/local/path1/water%{REQUEST_URI}是正确的构造并且它引用了正确的文件。但是...您仅将它们(这两个条件)应用于第一个重写规则...

3.据我了解,这些规则位于服务器配置/VirtualHost 上下文中,而不是 .htaccess 中。

把所有这些放在一起,你应该试试这个:

RewriteEngine on

RewriteCond /local/path1/water%{REQUEST_URI} !-d
RewriteCond /local/path1/water%{REQUEST_URI} !-f
RewriteRule ^/water/css/([^/]+\.css)$ /water/css.php?src=$1 [L,PT]

RewriteCond /local/path1/water%{REQUEST_URI} !-d
RewriteCond /local/path1/water%{REQUEST_URI} !-f
RewriteRule ^/water/js/([^/]+\.js)$ /water/js.php?src=$1 [L,PT]
于 2011-09-09T00:16:26.193 回答