Please convert this mod rewrite rule

Hi,

# Tell PHP that the mod_rewrite module is ENABLED.

SetEnv HTTP_MOD_REWRITE On
Options +FollowSymLinks
RewriteEngine on
RewriteRule test-(.).htm$ inc/tesmodrewite.php?q=test_$1
RewriteRule test2-(.
).htm$ /inc/tesmodrewite.php?q=test_$1
RewriteRule pm-(.).(jpg|png|gif|html)$ index.php?pm=$1
RewriteRule pt-(.
).(jpg|png|gif|html)$ index.php?pt=$1
RewriteRule dt-(.).(jpg|png|gif)$ index.php?dt=$1
RewriteRule dm-(.
).(jpg|png|gif)$ index.php?dm=$1
RewriteRule di-(.).(jpg|jpeg|png|gif|bmp)$ index.php?di=$1
RewriteRule page(.
).html$ gallery.php?p=$1

Thanks

Thanks

Posted at Nginx Forum:

On Mon, Apr 11, 2011 at 06:15:09PM -0400, alex1950 wrote:

Hi there,

RewriteRule test-(.).htm$ inc/tesmodrewite.php?q=test_$1
RewriteRule test2-(.
).htm$ /inc/tesmodrewite.php?q=test_$1
RewriteRule pm-(.*).(jpg|png|gif|html)$ index.php?pm=$1

As some starting notes:

  • replace “RewriteRule” with “rewrite”
  • stick a “;” at the end of the line
  • the first character of the request is “/”
  • the replacement probably wants to start with “/”
  • debug log is your friend

The third note is relevant if your regex starts with “^”. None of yours
here do.

For the fourth note, do you want “/a/b/test-c.htm”
to be rewritten to “/inc/tesmodrewite.php?q=test_c” or to
“/a/b/inc/tesmodrewite.php?q=test_c”? (The answer is probably obvious
to one who knows the apache syntax well.) You’ll want the leading “/”
either explicitly, or as part of a (new) initial (.*) in the regex and
corresponding $1 in the replacement.

Good luck with it,

f

Francis D. [email protected]

rewrite /test-(.).htm$ /inc/tesmodrewite.php?q=test_$1;
rewrite /test2-(.
).htm$ /inc/tesmodrewite.php?q=test_$1;
rewrite /pm-(.).(jpg|png|gif|html)$ /index.php?pm=$1;
rewrite /pt-(.
).(jpg|png|gif|html)$ /index.php?pt=$1;
rewrite /dt-(.).(jpg|png|gif)$ /index.php?dt=$1;
rewrite /dm-(.
).(jpg|png|gif)$ /index.php?dm=$1;
rewrite /di-(.).(jpg|jpeg|png|gif|bmp)$ /index.php?di=$1;
rewrite /page(.
).html$ /gallery.php?p=$1;

i added this in my htaccess file but not working ! :frowning:

  • debug log is your friend ( how can i Create or Access to that ? )

Note : I’m Root Access !

Posted at Nginx Forum:

Nginx does not support .htaccess files. You need to add the rewrite
rules to the server configuration and reload nginx.

alex1950 [email protected] schrieb:

rewrite /test-(.).htm$ /inc/tesmodrewite.php?q=test_$1; rewrite
/test2-(.
).htm$ /inc/tesmodrewite.php?q=test_$1; rewrite
/pm-(.).(jpg|png|gif|html)$ /index.php?pm=$1; rewrite
/pt-(.
).(jpg|png|gif|html)$ /index.php?pt=$1; rewrite
/dt-(.).(jpg|png|gif)$ /index.php?dt=$1; rewrite
/dm-(.
).(jpg|png|gif)$ /index.php?dm=$1; rewrite
/di-(.).(jpg|jpeg|png|gif|bmp)$ /index.php?di=$1; rewrite
/page(.
).html$ /gallery.php?p=$1; i added this in my htaccess file but
not working ! :frowning: * debug log is your friend ( how can i Create or Access
to that ? ) Note : I’m Root Access ! Posted at Nginx Forum:

nginx mailing list [email protected]
http://nginx.org/mailman/listinfo/nginx

On Mon, Apr 11, 2011 at 06:15:09PM -0400, alex1950 wrote:

RewriteRule pm-(.).(jpg|png|gif|html)$ index.php?pm=$1
RewriteRule pt-(.
).(jpg|png|gif|html)$ index.php?pt=$1
RewriteRule dt-(.).(jpg|png|gif)$ index.php?dt=$1
RewriteRule dm-(.
).(jpg|png|gif)$ index.php?dm=$1
RewriteRule di-(.).(jpg|jpeg|png|gif|bmp)$ index.php?di=$1
RewriteRule page(.
).html$ gallery.php?p=$1

If you want to use configuraiton which will be easy to maintain in
future,
do not use rewrite’s:

location /test- {
     location ~ ^/test-(.+)\.htm$ {
         fastcgi_pass   ...
         fastcgi_param  SCRIPT_FILENAME 

/path/to/inc/tesmodrewite.php;
fastcgi_param QUERY_STRING q=test_$1;

}
}

location /test2- {
     location ~ ^/test2-(.+)\.htm$ {
         fastcgi_pass   ...
         fastcgi_param  SCRIPT_FILENAME 

/path/to/inc/tesmodrewite.php;
fastcgi_param QUERY_STRING q=test_$1;

}
}

Yes, the configuration will be larger, but every location is independent
and may be changed or new locations may be added without worry how it
will affect other parts of the configuration.


Igor S.