1

I just transferred my website from GoDaddy (Apache) to DigitalOcean (Nginx/LEMP). The Web site was developed using PHP/CodeIgniter. I am only able to see the first page (index.php). It works if I provide the full URL of any file, but I cannot access URL rewrites. Looks like some issue with my .htaccess file...

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    Options -Indexes
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Any help or link/tutorial on how to move from Apache to Nginx will be helpful.

2
  • Show your htaccess Commented Sep 10, 2016 at 13:58
  • Nginx does not use .htaccess, that's an Apache configuration file. Commented Sep 10, 2016 at 14:28

1 Answer 1

2

I figured it out.

Your whole rewrite rule converted to one line

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

to

location / {
    try_files $uri $uri/ /index.php?$args;
}

The update/edit your default nginx file by

nano /etc/nginx/sites-available/default

and restart the service

sudo nginx service restart

Thanks for thos who looked and replied.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.