Replace apache with nginx

Christian Ivanov christianivanov2016 at gmail.com
Thu May 5 08:25:18 UTC 2016


Hello there. I want to migrate my website only on nginx. I setup
everything, but have issue with my htaccess.

Here is the file:

[root at server]# cat .htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^audio-(.*)\.html$ %{ENV:BASE}/audio_redirect_mask.php [L]
    RewriteRule ^s/(.*)$ %{ENV:BASE}/audio_redirect_source.php?u=$1 [L]
</IfModule>
[root at server]#

Somebody to have good idea, how can I replace this htaccess and execute
rewrite, without mod_php with apache or php-fpm?

Here is the source of both PHP files:
------------------------------------------------------------------------------------------------------------

[root at server]# cat audio_redirect_mask.php
<?php

if (empty($_GET['j'])) {
        $url = '/';
} else {
    $str = str_replace(array('-', '_'), array('/', '+'), $_GET['j']);
    $url = '/s/' .  base64_encode(openssl_decrypt($str, 'AES-256-CBC',
'somesecretpassword2222', 0, '1234567891011121000'));
}

header("location: $url", true, 302);
------------------------------------------------------------------------------------------------------------

[root at server]# cat audio_redirect_source.php
<?php

if ($_GET['u']) {
        header("X-Robots-Tag: noindex", true);
        header('Location: ' . base64_decode($_GET['u']) , true, 302);
} else {
        header("X-Robots-Tag: noindex", true);
        header("location: /");
------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160505/df2dd967/attachment.html>


More information about the nginx mailing list