How to set and customise redirect?

No .htaccess file is allowed on the server because of using Nginx for a web server on our AMI.

Two ways to redirect access

  1. Use WordPress plugin (easy)
  2. Modifying /etc/nginx/conf.d/example.conf to set up redirect


Use WordPress plugin (easy)

You can use any WordPress plugins for redirecting access. For example,

Easy to set up.

  1. Install and activate;
  2. Input Source URL which means redirect from;
  3. Input Target URL which means redirect to;
  4. Save changes
  5. Try and check your redirections are works correctly.

These plugins have import and export feature; you can set many redirects at once. If you want to use a regular expression, Redirection plugin has it as its feature.



Modifying /etc/nginx/conf.d/example.conf to set up redirect

Here is some example.

Redirect to

Add following block after include /etc/nginx/drop; block.

location / {
        return 301$request_uri;

Like this:

$ sudo su -
# vi etc/nginx/conf.d/

server {
    listen      80;;
    root        /var/www/vhosts/;
    index       index.html index.htm;
    charset     utf-8;

    access_log  /var/log/nginx/  main;
    error_log   /var/log/nginx/;

    include     /etc/nginx/drop;

    location / {
        return 301$request_uri;

server {
    listen      80;

# [other many configurations]


For more detail of rewrite rules, please check Nginx's official blog and documents: 


Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk