openresty / echo-nginx-module

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
http://wiki.nginx.org/NginxHttpEchoModule
BSD 2-Clause "Simplified" License
1.17k stars 254 forks source link

how to use echo in .htaccess file ? #50

Open Kooooooma opened 8 years ago

Kooooooma commented 8 years ago

i had already installed echo module for my nginx, and also i can use the echo command in the main nginx config file nginx.conf. but when i use the seem command in my .htaccess file it dosent't work anymore.

please help me, thanks!

agentzh commented 8 years ago

@KomaBeyond Well, I didn't know nginx supports .htaccess files like apache httpd.

Kooooooma commented 8 years ago

@agentzh well, actually it supports. could u make some tests and let echo can work in the .htaccess file ?

agentzh commented 8 years ago

@KomaBeyond You mean some 3rd-party modules? I've been working on the nginx core for 7 years now and I never see such things in the standard nginx distributions, ever.

Kooooooma commented 8 years ago

@agentzh Ah... I think may be we are not in the same topic now, so, let me paste my nginx config file and my .htaccess file down here, this will be show u how i used the .htaccess file in the nginx config file and then u will be know what i am talking about.

nginx config file contents:

server {
location / {
....

work better

    echo "hi, koma";  
}  
...  
include "/path/to/htaccess/.htaccess";  

}

.htaccess file contents:

location ~ /stream/view {

not work

echo "hi, koma, see u again..";  

}

rugk commented 8 years ago

Ha, that's really confusing. So basically you must use the correct nginx syntax in the .htaccess file. That's why naming it like this is already misleading (as everybody else uses Apache syntax there). In your case I would guess you do not need the RegExp location there and try location /stream/view { instead of location ~ /stream/view {. Don't know whether this fixes the problem, but it is a good thing to change in any way.

BTW: You can place code parts into newline/code/newline to show them nicely in Markdown here on GitHub.

ryandesign commented 2 years ago

Based on what you showed, the location directive in your .htaccess file isn't inside a server directive, but location directives must be inside server directives.