Howdy, Stranger!

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


Nginx rewrite help
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 rewrite help

eKoeKo Member

I seek for help about a rewrite rule please:

I need to trasform the following url :
doma.in/t.php?id=somelettersnumbers
to
doma.in/hello/somelettersnumbers

Any help is really appreciated!
Thanks!

Comments

  • Is this for wordpress?

  • eKoeKo Member

    @AuroraZ said:
    Is this for wordpress?

    Im afraid not.

  • hzrhzr Member
    rewrite ^/hello/([a-z0-9]+)$ /t.php?id=$1 last;
    Thanked by 1sureiam
  • sureiamsureiam Member
    edited January 2018

    @hzr said:

    I'm shocked cloudflare didn't think you were trying to take over the website! ;)

    Thanked by 2jetchirag Janevski
  • jetchiragjetchirag Member
    edited January 2018

    @sureiam said:

    @hzr said:

    I'm shocked cloudflare didn't think you were trying to take over the website! ;)

    their filters are like:

    
    if "/etc/hostѕ" in post:
        block
    else:
        pass
    
    Thanked by 1Janevski
  • mfsmfs Banned, Member

    @hzr said:
    rewrite ^/hello/([a-z0-9]+)$ /t.php?id=$1 last;

    shouldn't it be
    rewrite ^/t.php?id=(\w+)$ /hello/$1 last;

  • hzrhzr Member

    IIRC, that includes _ also, which isn't really 'somelettersnadnumbers'

  • mfsmfs Banned, Member
    edited January 2018

    yep, \w is equivalent to [a-zA-Z0-9_], I was talking more about the ordering of the arguments

  • @mfs said:
    yep, \w is equivalent to [a-zA-Z0-9_], I was talking more about the ordering of the arguments

    Yep, that got me thinking too

  • eKoeKo Member

    it worked this way:

    location /hello/ {
    rewrite ^/hello/(.*)$ /t.php?id=$1 last;
    }

    thanks for the help!

  • mfsmfs Banned, Member
    edited January 2018

    eKo said: it worked this way:

    well, something doesn't add up to me; it may be helpful to enable rewrite logs and double check error.log

    that should match /hello/something?randomargs and rewrite it to /t.php?id=something?randomargs (the opposite of what you requested?)

  • happybeehappybee Member, Host Rep
    edited January 2018

    I hope you already have the simultaneous Apache rules. If so try this URL - https://winginx.com/en/htaccess

    It does help with the majority of the conversions to Nginx.

Sign In or Register to comment.