Hello
I have urls like example.com/123
I need them rewritten to example.com/?v=123
However, I want to skip certain directories from rewrite
eg.
example.com/status
example.com/admin
right now I have this:
if (!-e $request_filename){
rewrite ^/([A-Za-z0-9-]+)/?$
http://www.example.com/v.php?dl=$1redirect;
}
Problem is that all urls are rewritten.. how do I put some exceptions?
Thanks for any suggestion
on 2012-11-28 09:05
on 2012-11-28 09:07
On Wed, Nov 28, 2012 at 3:04 PM, Cristian Rusu <crirus@gmail.com> wrote: > right now I have this: > > if (!-e $request_filename){ > rewrite ^/([A-Za-z0-9-]+)/?$ http://www.example.com/v.php?dl=$1 > redirect; > } > > Problem is that all urls are rewritten.. how do I put some exceptions? > put the rewrite in a location block (e.g. inside location / { }).
on 2012-11-28 09:31
Hello! On Wed, Nov 28, 2012 at 10:04:58AM +0200, Cristian Rusu wrote: > right now I have this: > > if (!-e $request_filename){ > rewrite ^/([A-Za-z0-9-]+)/?$ http://www.example.com/v.php?dl=$1redirect; > } > > Problem is that all urls are rewritten.. how do I put some exceptions? I would recommend using location matching to differentiate URIs which should be handled differently. E.g. location / { # you may want to use try_files here instead if (...) { rewrite ... } ... } location /status { ... } location /admin { ... } See http://nginx.org/r/location for more information. -- Maxim Dounin http://nginx.com/support.html
on 2012-11-28 13:11
Excellent, it worked I have another urgent matter on a server live we just switched to I need that links like this: http://www.example.com/?v=JYH253CT to be rewritten as http://www.example.com/v.php?dl=JYH253CT Please help, server is down :( --------------------------------------------------------------- Cristian Rusu Web Developement & Electronic Publishing ====== Crilance.com Crilance.blogspot.com
on 2012-11-28 13:26
On Wed, Nov 28, 2012 at 7:11 PM, Cristian Rusu <crirus@gmail.com> wrote: > Please help, server is down :( > http://nginx.org/en/docs/http/ngx_http_core_module... Maybe something like this. location = / { if ($arg_v) { rewrite ^ /v.php?dl=$arg_v; } }
on 2012-11-28 13:34
On Wed, Nov 28, 2012 at 2:25 PM, Edho Arief <edho@myconan.net> wrote: > > > } > } > I tried this from a htaccess to nginx converter if ($query_string ~ "^v=(.*)$"){ rewrite ^/index\.php$ /v.php?dl=$1 break; } But the resulting url is /v.php?dl=%1&v=FER34S beats me!!
on 2012-11-28 13:59
>> > to be rewritten as http://www.example.com/v.php?dl=JYH253CT >> if ($arg_v) { >> rewrite ^ /v.php?dl=$arg_v; >> } >> } >> > > I tried this from a htaccess to nginx converter > > if ($query_string ~ "^v=(.*)$"){ > rewrite ^/index\.php$ /v.php?dl=$1 break; > } Try: if ($arg_v) { rewrite ^ /v.php?dl=$arg_v break; } --appa
on 2012-11-28 14:04
Yes, this worked, I was also trying to get an idea of that matching in my attempt... Why is $1 not matching right? --------------------------------------------------------------- Cristian Rusu Web Developement & Electronic Publishing ====== Crilance.com Crilance.blogspot.com
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.