Rewrite rule custom.php to custom.css

hi,

how can i rename custom.php to custom.css for my wordpress custom css.

let say i put my custom.php inside my theme folder

http://example.com/wp-content/themes/mytheme/assets/css/custom.php

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

On 4 Jan 2012 14h12 WET, [email protected] wrote:

hi,

how can i rename custom.php to custom.css for my wordpress custom
css.

You mean rewrite or redirect I suppose.

let say i put my custom.php inside my theme folder

http://example.com/wp-content/themes/mytheme/assets/css/custom.php

Try:

location ^~ /wp-content/themes/mytheme/assets/css/custom.php {
return 302 /wp-content/themes/mytheme/assets/css/custom.css;
}

— appa

it’s not redirect. i have .php file, but no .css file.

if in apache, rewrite rule is like this :

RewriteEngine On RewriteRule custom.css custom.php [L,QSA]

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

If you want it mod_rewrite style (so no 302 Temporary Redirect header):

location ^/wp-content/themes/mytheme/assets/css/ {
rewrite custom.css custom.php;
}

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

On 7 Jan 2012 14h00 WET, [email protected] wrote:

If you want it mod_rewrite style (so no 302 Temporary Redirect
header):

location ^/wp-content/themes/mytheme/assets/css/ {
rewrite custom.css custom.php;
}

Why this? Nginx is not Apache. There’s no need for rewrites, in fact
in most mod_rewrite -> nginx conversions you won’t need them at all,
IMO.

If you want to return a 301 then just replace the 302 by 301.

Furthermore the ‘^/’ doesn’t function since there’s no ~ or ~* to denote
a regex based location.

— appa

On 4 Jan 2012 14h41 WET, [email protected] wrote:

it’s not redirect. i have .php file, but no .css file.

if in apache, rewrite rule is like this :

RewriteEngine On RewriteRule custom.css custom.php [L,QSA]

It’s the other way around:

location ^~ /wp-content/themes/mytheme/assets/css/custom.css {
return 302 /wp-content/themes/mytheme/assets/css/custom.php;
}

— appa

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