Welcome! Log In Create A New Profile

Advanced

(from Apache) Rewrite .php to .zpc

Posted by Erin 
(from Apache) Rewrite .php to .zpc
August 01, 2011 11:13AM
Hi,

I am moving a script I wrote from a Apache server to Nginx and am having troubles with mod rewrite.
So my question is, how would I rewrite this for Nginx?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^([^.]+)\.zpc$ $1.php [L]
RewriteRule ([^/\.]+)/?.zpc$ mainpage.php?page=$1 [L]
RewriteRule ^article/([^-]+)-([^&]+)\.zpc$ /articles.php?article_id=$1&article_name=$2 [L]
</IfModule>

Clients must be able to execute .zpc files as php files so they wouldn't see the extension.

Thanks,
Erin



Edited 1 time(s). Last edit at 08/01/2011 11:14AM by Erin.
Re: (from Apache) Rewrite .php to .zpc
August 09, 2011 08:48AM
Try the following:

server ... {

[...]

rewrite ^/article/([^-]+)-([^&]+)\.zpc$ /articles.php?article_id=$1&article_name=$2 last;
rewrite ([^/]+)/\.zpc$ mainpage.php?page=$1 last;
rewrite ^(.+)\.zpc$ $1.php last;

[...]

}



Edited 1 time(s). Last edit at 08/09/2011 08:48AM by locojohn.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 233
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