I want to change all requests to a file with the extension .user.js to be made to a .php. I have this code:
<IfModule mod_rewrite.c>
RewriteEngine on
Rewr开发者_C百科iteRule /([^/]*)\.user\.js$ $1.php [R,NC]
</ifModule>
That unfortunately does not work. I know mod_rewrite is loaded because, if I do this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule /([^/]*)\.user\.js$ $1.php [R,NC]
s
</ifModule>
It returns a status code of 500. So I believe my problem is in the regex.
Example of what I want:GET /foo/bar/preetyuserscript.user.js
becomes
GET /foo/bar/preetyuserscript.php
I think this will work:
RewriteRule ^(.*?)\.user\.js$ $1.php
If it doesn't and you continue to see 500 errors have a look in the error log. Always the first place to check out.
Correct RewriteRule should be:
RewriteRule ^([^.]*)\.user\.js$ /$1.php [R,L,NC]
精彩评论