I am currently migrating my website from Apache to nginx
, but my .htaccess
file is not working. My website is inside the /usr/share/nginx/html/mywebsite
folder. How can I use .htaccess
in my nginx
server?
This is my .htaccess
file:
RewriteEngine on RewriteRule video/watch/([a-zA-Z0-9_@$*-]+)/?$ "videos-single.php?id=$1" [NC]
Nginx does not use . htaccess files like Apache does. This means that configuration previously done in . htaccess files now has to be done in a different format, explained in the Nginx documentation.
htaccess for nginx enables the nginx high performance webserver to deal with . htaccess files. . htaccess files are mainly used for access control and URL rewrite instructions and are widely known across the web community.
Nginx doesn't support .htaccess
(see here: "You can’t do this. You shouldn’t. If you need .htaccess, you’re probably doing it wrong.").
You've two choices (as I know):
.htaccess
to nginx.conf
(maybe the htaccess to nginx converter helps you)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With