Welcome! Log In Create A New Profile

Advanced

Re: rewrite question - "(css/js).php" to "(.css/.js)"

Francis Daly
October 24, 2010 07:34AM
On Sat, Oct 23, 2010 at 10:30:41PM -0400, voku wrote:

Hi there,

> 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;
> }
> }
<snip>

> 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! :-)

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!?!? :-)

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 Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

voku October 23, 2010 04:43PM

Re: rewrite question - "(css/js).php" to "(.css/.js)"

Francis Daly October 24, 2010 07:34AM

Re: rewrite question - "(css/js).php" to "(.css/.js)"

voku October 24, 2010 11:59AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 311
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready