Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

[Help] Nginx + PHP-fpm rewrite rule

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
gati
Posts: 3
Joined: Sun Apr 29, 2018 12:02 pm

Os: CentOS 6x
Web: nginx + php-fpm
[Help] Nginx + PHP-fpm rewrite rule
  • Quote

Post by gati » Sun Apr 29, 2018 12:12 pm

Please help write 301 redirect for urls which contains some parameters.

Example:

/page/2/?__hstc=85203782.2a1e835c34ab7bf88e972fdd7a7debc8.1479686400000.1479686400000.1479686400000.1&__hssc=85203782.1.1479686400000&__hsfp=528229161

rewrite to /page/2/

/page/232/?__hstc=85203782.2a1e835c34ab7bf88e972fdd7a7debc8.1479686400000.1479686400000.1479686400000.1&__hssc=85203782.1.1479686400000&__hsfp=528229161

rewrite to /page/232/

/someurl/?__hstc=85203782.2a1e835c34ab7bf88e972fdd7a7debc8.1479686400000.1479686400000.1479686400000.1&__hssc=85203782.1.1479686400000&__hsfp=528229161

rewrite to /someurl/

I'm write at domain nginx config at location / section:

if ($query_string ~ "^__hstc=.+$"){
rewrite ^(.*)$ /$request_uri? redirect;
}

But it's not work...
Top

noogen
Posts: 66
Joined: Thu Jan 05, 2017 9:20 pm

Re: [Help] Nginx + PHP-fpm rewrite rule
  • Quote

Post by noogen » Wed May 02, 2018 6:28 pm

if ($request_uri ~ "([^\?]*)\?(.*)__hstc=([^&]*)&?(.*)") {
set $original_path $1;
set $args1 $2;
set $unwanted $3;
set $args2 $4;
set $args "";

rewrite ^ "${original_path}?${args1}${args2}" redirect;
}

ref: https://stackoverflow.com/questions/263 ... r-from-url
Top


Post Reply
  • Print view

2 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password