0

Hi all I am trying to convert the following .htaccess code

<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^arrowchat/chatroom ^/chatroom/ [L] RewriteRule ^arrowchat/cron ^/cron/ [L] RewriteRule ^arrowchat/debug ^/debug/ [L] RewriteRule ^arrowchat/list ^/list/ [L] RewriteRule ^arrowchat/mobile ^/mobile/ [L] RewriteRule ^arrowchat/popout ^/popout/ [L] RewriteRule ^arrowchat/video ^/video/ [L] </IfModule> 

This is what I came up with

if ($rule_0 = "2"){ rewrite ^/arrowchat/chatroom ^/chatroom/ last; } rewrite ^/arrowchat/cron ^/cron/ last; rewrite ^/arrowchat/debug ^/debug/ last; rewrite ^/arrowchat/list ^/list/ last; rewrite ^/arrowchat/mobile ^/mobile/ last; rewrite ^/arrowchat/popout ^/popout/ last; rewrite ^/arrowchat/video ^/video/ last; 

On trying to reload the nginx conf files by running the command nginx -s reload I am getting an error msg

nginx: [emrg] unknown "rule_0" variable 

My current default.conf file for nginx looks like this

# # The default server # server { listen 80; server_name jukpac.com; return 301 http://www.jukpac.com$request_uri; } server { listen 80; server_name www.jukpac.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; if ($rule_0 = "2"){ rewrite ^/arrowchat/chatroom ^/chatroom/ last; } rewrite ^/arrowchat/cron ^/cron/ last; rewrite ^/arrowchat/debug ^/debug/ last; rewrite ^/arrowchat/list ^/list/ last; rewrite ^/arrowchat/mobile ^/mobile/ last; rewrite ^/arrowchat/popout ^/popout/ last; rewrite ^/arrowchat/video ^/video/ last; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } location ~* \.(?:ico|css|js|gif|jpe?g|png|swf)$ { expires 30d; add_header Pragma public; add_header Cache-Control "public"; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 

Can anyone help me out a bit with the rewrite rules?

7
  • I think I saw this question on stackoverflow a couple of days ago, I think your whole config needs few things, like what's the main root for the wesbite? and whats /arrowchat is it required in the URL ? Commented Jan 5, 2014 at 14:35
  • @MohammadAbuShady I am struggling with this issue for a month now, no one seems to answer me :( I would be happy to answer whatever details you need in the hopes that I can get this running. The main root for the site is /usr/share/nginx/html and /arrowchat is the folder inside which the arrowchat files are located and it is required in the url Commented Jan 5, 2014 at 14:40
  • Is it what YOU want? or is it there because that's just how you found it works ? do you have a domain name ? or is it a localhost project Commented Jan 5, 2014 at 14:43
  • It has a domain name www.jukpac.com I was using it earlier in an apache based VPS I would login using the link www.jukpac.com/arrowchat/admin but now when I try it doesn;t work properly the static files don't load, sometimes if i try to open the file 'www.jukpac.com/arrowchat/admin/css/index.html' I get a 404 error even though I can use FTP and see that the index.html file is right there. I am tweaking with the .conf files and sometimes i can make something work but something else crashes. I need the correct and complete rules Commented Jan 5, 2014 at 14:46
  • what does the main domain go to? is there another site that's hosted on that? without the /arrowchat, and if it is, is it still on apache Commented Jan 5, 2014 at 14:48

1 Answer 1

0

Gonna remove some unnecessary stuff and clean the rest for your default.conf, try this and reload nginx and tell me if it works.

server { #redirecting server listen 80; server_name jukpac.com; return 301 http://www.jukpac.com$request_uri; } server { listen 80; server_name www.jukpac.com; root /usr/share/nginx/html; #move the root to server level index index.php # move index to server level error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location / { try_files $uri $uri/ =404; } location ~* \.(?:ico|css|js|gif|jpe?g|png|swf)$ { expires 30d; add_header Pragma public; add_header Cache-Control "public"; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.