Rewrite question - "(css/js).php" to "(.css/.js)"

Hi, I want to speed up my WordPress-Blog and so I want to cache
“css.php”, “js.php” files to “.css”, “.js”

for example I want to rewrite … this ->

http://suckup.de/wp-content/plugins/wp-special-textboxes/css/wp-special-textboxes.css.php?ver=3.0.1

to…

http://suckup.de/wp-content/cache/wp-special-textboxes.css


I had experiment with this rule…

    [code]

Optimierung - “(css/js).php” to “(css/js)”

    location /wp-content/plugins/wp-special-textboxes/css/ {
            if ($args ~ "ver=(.*)") {
                    rewrite ^/?(.*)

$scheme://$host/wp-content/cache/wp-special-textboxes.css permanent;
}
}
location /wp-content/plugins/wp-special-textboxes/js/ {
if ($args ~ "ver=(.)") {
rewrite ^/?(.
)
$scheme://$host/wp-content/cache/wstb.js permanent;
}
}
[/code]

but this only rewrite

http://suckup.de/wp-content/plugins/wp-special-textboxes/css/?ver=3.0.1

to…

http://suckup.de/wp-content/cache/wp-special-textboxes.css?ver=3.0.1


Can someone please help me, thx! :slight_smile:

I have a second problem with the rewrite… I use varnish on port 80 and
nginx on port 8080, but some files from my WordPress-Theme want to use
something like this "@import
http://suckup.de:8080/blog/2010/07/26/webseiten-analyse/?mystique=css

… can someone say me how to rewrite the port to 80, thx??? :slight_smile:

Mfg
Voku

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,143927,143927#msg-143927

On Sat, Oct 23, 2010 at 10:30:41PM -0400, voku wrote:

Hi there,

I had experiment with this rule…

    [code]

Optimierung - “(css/js).php” to “(css/js)”

    location /wp-content/plugins/wp-special-textboxes/css/ {
            if ($args ~ "ver=(.*)") {
                    rewrite ^/?(.*)

$scheme://$host/wp-content/cache/wp-special-textboxes.css permanent;
}
}

Can someone please help me, thx! :slight_smile:
If the question is “how do I avoid the ?ver=3.0.1 in the rewritten
output”, http://wiki.nginx.org/HttpRewriteModule#rewrite suggests adding
“?” as the last character of the rewrite rule. Possibly the shorter rule

rewrite ^ /wp-content/cache/wp-special-textboxes.css? permanent;

would do, but you can experiment with the other changes to see if they
suit your setup. (nginx fills in a scheme://host in this case.)

If the question is “why is
http://suckup.de/wp-content/plugins/wp-special-textboxes/css/wp-special-textboxes.css.php?ver=3.0.1
apparently not processed by this rule”, the output you do see should
give
a hint, and http://wiki.nginx.org/HttpCoreModule#location should explain
why it happens. Possibly you want to add “^$” after the “location” word.

I have a second problem with the rewrite… I use varnish on port 80 and
nginx on port 8080, but some files from my WordPress-Theme want to use
something like this "@import
http://suckup.de:8080/blog/2010/07/26/webseiten-analyse/?mystique=css

… can someone say me how to rewrite the port to 80, thx??? :slight_smile:

If you really want to rewrite in nginx, look into modules with names
like
“substitution”

I think you’re better off finding what is writing the thing you don’t
want, and getting it to stop. So, check the WordPress-Theme and see
what it is doing. Either disable the scheme://host:port bit altogether
(since the browser knows to use the same scheme://host for subsequent
requests), or see where it gets its information from and change it. At
a guess, the fastcgi_params SERVER_PORT and SERVER_NAME, or HTTP_HOST
that gets sent to the php interpreter, are probably involved.

Good luck with it,

f

Francis D. removed_email_addre[email protected]

Hi, thx for the help… :slight_smile: … this is what I made ->

[code]

Optimierung - “(css/js).php” to “(css/js)”

    location /wp-content/plugins/wp-special-textboxes/css/ {
            location ~* \.(css.php)$ {
                    if ($args ~* ver=(.*)$) {
                            rewrite ^

$scheme://$host/wp-content/cache/wp-special-textboxes.css? permanent;
}
}
}
location /wp-content/plugins/wp-special-textboxes/js/ {
location ~* .(js.php)$ {
if ($args ~* ver=(.*)$) {
rewrite ^
$scheme://$host/wp-content/cache/wstb.js? permanent;
}
}
}
[/code]

and a second thx for the tip with the “SERVER_PORT” :slight_smile: … I found this
in the theme …

$pageURL .=
$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$request;

und changed it to …

$pageURL .= $_SERVER["SERVER_NAME"].":80".$request;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,143927,144072#msg-144072

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs