开发者

Make mod_alias work with mod_rewrite

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


1. I do not have much experience working with mod_alias .. but I think you are doing wrong by rewriting to /local/path1/water/ -- mod_rewrite does URL rewriting, so it should be URL here as well.

2. I will assume that /local/path1/water%{REQUEST_URI} is correct construction and it references correct file. But ... you apply them (these 2 conditions) to a first rewrite rule only ...

3. As I understand these rules are placed in server config / VirtualHost context and not in .htaccess.

Taking all this together you should try this instead:

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]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜