Welcome! Log In Create A New Profile

Advanced

Wordpress htaccess for URL

Posted by missbelle 
Wordpress htaccess for URL
February 29, 2016 12:48PM
I'd love some help, already struggling for 2 weeks on this one:

I'm moving my Wordpress form Apache to Nginx.

On Apache we used .htaccess

<IfModule mod_rewrite.c>
RewriteRule ^business/([^/]*)/([^/]*)$ /business/?id=$1 [L,P]
</IfModule>

to create this nice looking URL of each user's profile page website.com/business/6/company-name
in which 6 is the user ID and company-name the user's company (the url works with any text behind the 6)

In Ngnix I want the same:

When someone types website.com/business/6/company-name
he should get the data from website.com/business/?id=6
but see the URL still as website.com/business/6/company-name

All I've achieved is for website.com/business/6/company-name to redirect website.com/business/?id=6

location /business-profile {
rewrite ^/business-profile/([^/]*)/([^/]*)$ /business/?id=$1? redirect;
}

How do I make it so that the user only sees my nice URL website.com/business/6/company-name ?

Any help much appreciated!
Re: Wordpress htaccess for URL
February 29, 2016 02:01PM
I'm confused. You seem to be using two different locations: /business-profile and /business.

I think if you really meant for it to be /business, then try:

location /business {
rewrite ^/business/([^/]*)/([^/]*)$ /business/?id=$1 last;
}

--
Jim Ohlstein
Re: Wordpress htaccess for URL
March 02, 2016 07:35AM
Thanks Jim. Unfortunately it didn't work.. I guess we're going to have to stick to the query.
Re: Wordpress htaccess for URL
July 28, 2023 10:02AM
.htaccess is used in Nginx to move site from Wordpress? i want to do for my https://www.thegolfcrunch.com/ site. Kindly let me know.



Edited 2 time(s). Last edit at 07/28/2023 10:04AM by Jimmywatson.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready