Enabling Nginx Mod_Rewrite
I just moved a Wordpress blog on a new droplet hosting account. Previously the hosting was on Apađậy, now is on Nginx. I have sầu a problem that now Wordpress pretty liên kết (post-name) are not working và I think the problem comes from the fact that mod)rewrite is not enabled.
Bạn đang xem: Enabling nginx mod_rewrite
Till now I had it in htaccess like
RewriteEngine OnRewriteBase /RewriteRule ^index.php$ -
How can I implement this in Nginx và where specifically? I am a complete beginner.
Add a comment
Subscribe Subscribed
Share
Report

By:
albasiero
Related
NGINX Config Generator

Easily configure a performant, secure, & stable NGINX VPS.
Learn MoreWordpress FTP. password & recommenced ebooks for linux, centos and server management Question
403 Forbidden in nginx on Centos 7 Question
Add a comment
Leave a comment
Sign In to Comment
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run inkhổng lồ issues leave a bình luận, or add your own answer lớn help others.
×Submit an Answer
Submit an answer
You can type !ref in this text area lớn quickly search our full mix of tutorials, documentation & marketplace offerings và insert the link!
Sign In to Answer
14 answers
9
jesin March 10, 2015
Nginx does not support .htaccess files.
On CentOS Nginx stores virtual host files in /etc/nginx/conf.d. I assume you’re using the default.conf tệp tin. So edit this file & find the following:
location / root /usr/share/nginx/html; index index.html index.htm; và make the following change:
location / root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.php?$args; Save sầu the tệp tin and reload Nginx:
sudo service nginx reload
Reply Report
4
UKn0Me March 7, năm ngoái
In your site’s hệ thống blochồng add /index.php?$args;khổng lồ try_files so that you get something like this:
try_files $uri $uri/ /index.php?$args;
Then go into lớn your Wordpress settings và re-enable pretty permalinks.
Reply Report
2
brianjes February 3, 2017
I have sầu the following:
try_files $uri $uri/ =404;Should I just replace the above sầu line with
try_files $uri $uri/ /index.php?$args;Or should I add it as a new line? Just curious about that before I commit to lớn the change.
Thank youBrian
Reply Report
1
paysofts January 28, 2016
My WORKED solution..!Already its mentioned by “UKn0Me March 7, 2015”
Plz follow:
Use filezilla, login khổng lồ your SSH-FTPhường. using top level SSH user (may ‘root’)Gokhổng lồ the path “/home/Domain-UserName/conf/web/nginx.conf”Probably you should see..Xem thêm: 3 Bước Để Tạo Nhóm Danh Bạ Trên Iphone ? 3 Bước Để Tạo Nhóm Danh Bạ Của Ios
try_files $uri $uri/ /index.php?$args;Here, Nginx checks for the existence of a tệp tin at the URL ($uri), then for a directory ($uri/).If it doesn’t find a directory or a file, it performs an internal redirect to lớn /index.php passing the query string arguments as parameters.
location / index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args;
If your blog is in a subthư mục (say /wordpress), you’ll have khổng lồ add an extra location /wordpress/ bloông chồng to lớn your configuration file :location /wordpress/ try_files $uri $uri/ /wordpress/index.php?$args;
Restart NGINX (or) may be whole server.
My hệ thống configs are:thangvi.com, Ubuntu 14x, Vesta Nginx+php-fpm, Wordpress on subfolder.
Reply Report
1
jerdog February 9, 2017
I followed the tutorial here (https://www.thangvi.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04) khổng lồ thiết lập Wordpress on NGINX & at the kết thúc of it I get the 404 page. I had
try_files $uri $uri/ /index.php?$args;in but that was giving the generic 404 - so I went back to
try_files $uri $uri/ =404;và I get a custom 404 I built. HOWEVER I am not getting the Wordpress index.php (gives the 404) but I can get the mặc định thangvi.com index.html
Reply Report
0
UKn0Me March 7, năm ngoái
The server bloông chồng is defined by
server ...By default it resides within the configuration file in /etc/nginx/sites-available
Reply Report
0
UKn0Me March 7, năm ngoái
Then it should be in /etc/nginx/nginx.conf
Reply Report
0
albasiero March 7, 2015
Reply
0
UKn0Me March 7, 2015
I’m not sure where it would be in CentOS.
Reply Report
0
albasiero March 18, 2015
Finally, there were needed the arguments to lớn nGinx config lớn the End Of File
$ nano /usr/local/apps/nginx/etc/conf.d/common
location / index index.php index.html index.htm;try_files $uri $uri/ /index.php?$args;
then Restart Nginx$ service nginx restart
And finally in WP-Admin –> settings–> Permalinks–>mix to lớn mặc định once… then mix lớn “Post Name” which rewrites WP rules.
This solved the issue for me, maybe it will also help anyone else.
Reply Report
Previous 1 2 Next
Load More Answers
Related
Looking for something else?
Ask a new question Search for more help

Get our biweekly newsletter
Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good
Working on improving health and education, reducing inechất lượng, và spurring economic growth? We'd lượt thích to help.

Become a contributor
You get paid; we donate khổng lồ tech nonprofits.
Featured on Community Kubernetes Course Learn Pyeo hẹp 3 Machine Learning in Pykhông lớn Getting started with Go Intro lớn Kubernetes thangvi.com Products Virtual Machines Managed Databases Managed Kubernetes Blochồng Storage Object Storage Marketplace VPC Load BalancersWelcome to lớn the developer cloud
thangvi.com makes it simple lớn launch in the cloud và scale up as you grow – whether you’re running one virtual machine or ten thousand.
Learn More
Company
Products
Community
Liên hệ
× Join the Community
Before you can bởi that To complete this action, sign in to lớn your Community trương mục or create a new one.
Sign In Sign Up
×
Community Products Customers