Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx users
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx users

cosmicgatecosmicgate Member
edited May 2012 in General

How do you deal with broken links from functions or scripts that rely on the mod_rewrite module?

Comments

  • Custom 404 page set to the index.php page or just use http://wiki.nginx.org/HttpRewriteModule

  • http://wiki.nginx.org/HttpRewriteModule looks very complicated. Where exactly do i put those codes into? Index.php/index.html?

  • very nice tool. Where do i put the converted code? Replace it into .htaccess file?

    Thanked by 1mrm2005
  • it goes in your nginx config file, in the "server" block for the website the rules apply to.

  • beardbeard Member

    Nginx does not use .htaccess files because .htaccess, according to the nginx developers, is slow. This was not posted for a 10 page Apache vs nginx discussion, just stating why the developers of nginx do not use .htaccess

  • @dmmcintyre3 said: it goes in your nginx config file, in the "server" block for the website the rules apply to.

    that didn't work. When i put it into the individual domain vhost nginx config file under the server block it broke the whole nginx and wouldn't start.

    @beard said: Nginx does not use .htaccess files because .htaccess, according to the nginx developers, is slow. This was not posted for a 10 page Apache vs nginx discussion, just stating why the developers of nginx do not use .htaccess

    sad but true. Time to move back to apache. sigh.

  • beardbeard Member

    You could hire some guy for $5 on some rentacoder site or even Fiverr for you to make custom rewrites for nginx

    What made you want to switch from Apache to nginx? Speed? Resource consumption?

    If the reason is because Apache chokes on connections, setup a nginx reverse proxy which makes the connection to localhost:8000 where Apache is listening. Nginx reverse proxy is pretty normal and well documented online

  • cosmicgatecosmicgate Member
    edited May 2012

    that might work. So just to get your method right,

    scenario: 1 IP, multiple domain names. Vhosts set at nginx

    1)Nginx set at port 80 and set as reverse proxy for domain X

    location / {
    proxy_pass http://127.0.0.1:8000;
    include /etc/nginx/proxy.conf;

    2)setup apache to listen at port 8000. How do i setup apache to only accept domain X connection? Do i need to setup virtual hosts too? Remember i have a couple domains, only domain x need to go through nginx as reverse proxy and to apache. I do not want it to use the default /var/www folder, instead i want it to use individual folder such as vhost1 /var/www/vhost1 for domain x, vhost2 /var/www/vhost2 for domain y.

    it sounds like it involves a lot of work.

  • You don't sound like you're fit for any of that 'lots of work'.

    Go hire an Indian or two off of Fiverr for $5, shouldn't take more than 5 mins for this.

    Thanked by 1beard
  • What script are you trying to make run on Nginx? Perhaps someone here has already crossed that bridge and can help you (unless it's some really esoteric stuff)

  • NubieNubie Member

    @cosmicgate mod_rewrite on Nginx??

    In case, if you migrate from "Apache .htaccess", some kind of basic tricks is to follow these rules:

    • RewriteRule becomes rewrite.
    • [QSA,L,NC] becomes last.
    • [QSA,L,R=301] becomes permanent.
    • In Nginx the rewrite rules require a forward slash (/) after the ^ character (in regex it means that the URL should start with a forward slash), while Apache doesn't require this.
    • In Nginx rewrite rules (these must always be terminated by a ; [semicolon]).
    • Nginx rewrite rules are NOT read from .htaccess files (this should be obvious), but from nginx.conf or from nginx vhost configuration file, depending on your configuration.
    • etc..

    I've many configured site/CMS with Nginx HttpRewriteModule, such as wordpress, phpbb, joomla, rapidleech, etc..

    The matter how you write those "Nginx HttpRewriteModule" may seem complicated, but they don’t have to be.
    :-)

    Thanked by 3tux beard mrm2005
  • This is why I tend to use Nginx as a proxy to apache. It avoids such headaches and accelerates apache.

  • @Nubie said: In Nginx the rewrite rules require a forward slash (/) after the ^ character (in regex it means that the URL should start with a forward slash), while Apache doesn't require this.

    In Nginx rewrite rules (these must always be terminated by a ; [semicolon]).

    finally got it working by following those tip!

  • bretonbreton Member

    @unixguru said:

    This is why I tend to use Nginx as a proxy to apache. It avoids such headaches and accelerates apache.

    This is why I don't use php and any software written in it, relying on specific webserver - apache.

  • debugdebug Member

    @breton said: This is why I don't use php and any software written in it, relying on specific webserver - apache.

    Pretty wide assumption based on a few scripts.

  • SpencerSpencer Member

    @debug said: Pretty wide assumption based on a few scripts.

    I agree. I know a lot of PHP scripts that dont require apache.

Sign In or Register to comment.