nginx rewrite help
-
so i just need a little help cause i'm having some problems wrapping my brain around the rewrite rules.
i have site called tamerax.com
when you go to the http://www.tamerax.com, it is supposed to automaticly forward you too tamerax.com/v3
this is my current set of rules:
server { listen 80; server_name http://www.tamerax.com; rewrite ^/(.*) http://tamerax.com/v3$1 permanent; }so this works fine. brings me right to tamerax.com/v3.
now the problem is if i just simply type tamerax.com into the browsers without the www, it doesn't redirect me but shows me the little test index file sitting in the web root.
What should the proper rule be because everytime i try adding anything in there, firefox tells me it trying to resolve a loop that will never resolve and the address bar saying something like "tamerax.com/v3v3v3v3v3v3v3v3v3v3v3v3"
once I get this solved, i pose my second question which is much more complicated and i don't think it is something you can do cause it involves SEF urls in joomla using a plugin.
Posted 2 years ago # -
vhost syntax issue.
post up the entire contents .. the bit needing correction will be in the location block
Posted 2 years ago # -
'
server {
listen 80;
server_name http://www.tamerax.com;
rewrite ^/(.*) http://tamerax.com/v3$1 permanent;
}server {
listen 80;
server_name tamerax.com;access_log /home/public_html/tamerax.com/log/access.log;
error_log /home/public_html/tamerax.com/log/error.log;location /
{root /home/public_html/tamerax.com/public/;
index index.php index.html;}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/public_html/tamerax.com/public/$fastcgi_script_name;
}
}
'Posted 2 years ago # -
try changing this line, Tamerax:-
root /home/public_html/tamerax.com/public/;
to:-
root /home/public_html/tamerax.com/public/v3;
.. 'cos that's the root you want, huh?
lemme know OK.
Posted 2 years ago # -
alas that didn't work. still can;t get "tamerax.com" to resolve forward automatic and not tamerax.com/v3 gives me a 404 error so i had to put it back to the old way. :(
Posted 2 years ago # -
soo....still having this issue. any more ideas?
Posted 2 years ago # -
Hi Tamerax,
Ok, 1st i am no expert of any sort. Could it be something to do with the 'www' sub-domain bit in the 'server_name' lines of the vhost file? How about having both tameraxdotcom and wwwdottameraxdotcom in 'server_name' lines code?Benjamin
Posted 2 years ago # -
hey tamerax,
try this, changing 2 lines:-
root /home/public_html/tamerax.com/public/;
goto
root /home/public_html/tamerax.com/public/v3/;
.. and ..
fastcgi_param SCRIPT_FILENAME /home/public_html/tamerax.com/public/$fastcgi_script_name;
goto
fastcgi_param SCRIPT_FILENAME /home/public_html/tamerax.com/public/v3/$fastcgi_script_name;
lemme know!
Posted 2 years ago # -
so i made that change and here is what happened:
going to http://www.tamerax.com shows the pages in /v3 which is good but doesn't show the address as http://www.tamerax.com/v3
not sure if thats good or bad but it might make troubleshooting later kinda hard :PIf i go to tamerax.com, it takes me to tamerax.com/v3 which gives me a 404 :(
edit: i had to take the /v3 out of the rewrite rule near the top and now both address variations go the right directory, it just doesn't show up in the address bar as such. this is fine for my tamerax site but won't work for one of my other joomla sites.
we're close!!
second edit: ok all the links of the site that aren't relative links don't work anymore. This won't work :(
Posted 2 years ago # -
hey tamerax .. re second edit .. maybe a redirection plugin for those?
Posted 2 years ago # -
after much pain and suffering and many many many attempts to help from several different people, we finally got it sorted out.
Posted 2 years ago # -
Congs. tamerax! Would you kindly share how u sorted the rewrite issue for your Joomla 1.5.nginx setup.
Many thanks,
Benjamin
Posted 2 years ago # -
I am keep getting this stupid 403 error
403 Forbidden
nginx/0.7.65anyone ran into this beast?
I am sure it is the vhost files.
Posted 2 years ago # -
alright resolved.
:) logs are the most useful thing in the directory.
in a haste i renamed the index.html to index.htm and i guess I dont had the permission for htm files huh!!!
wat a day time to sleep
so if anyone ran into 403 check the permissions
Posted 2 years ago #
Reply
You must log in to post.
Want HTML?
a blockquote code em strong ul ol liPlace code between backticks `codeHere`
You've got it.
