Report this

What is the reason for this report?

.htaccess re-writing not working in nginx .getting 404 error

Posted on April 15, 2016

This is the first time i am installing and configuring droplet with ngnix . this application was running in Apache and migrated to nginx . Unfortunately, .htaccess not working .

for example i have given htaccess for aboutus page http://82.196.8.251/about-us/ –RewriteRule ^about-us/ about_us.php [L,QSA] ,but its not working . could you please help me to fix this issue .

I can directly access like :http://82.196.8.251/about_us.php … But entire this project has been set in .htaccess list…

Thanks in advance !!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I have tried adding that … when I click on link the, source code getting downloaded . Please help or advice …

.htaccess file content example

RewriteRule ^about-us/ about_us.php [L,QSA]

/etc/nginx/sites-enabled/default

location @about-us{ rewrite ^(.*) /about_us.php?$1 last; } -----------------------------------------------------------------Entire .htaccessfile content below--------------------

RewriteEngine On Options +FollowSymLinks

RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f

SetEnv HTTP_MY_SITE_ROOT “http://82.196.8.251/” SetEnv HTTP_MY_SITE_ADMIN “http://82.196.8.251/admin/

RewriteRule ^about-us/ about_us.php [L,QSA]

#SetEnv HTTP_MY_SITE_ROOT “http://localhost/emmay/” #SetEnv HTTP_MY_SITE_ADMIN “http://localhost/emmay/admin/” #SetEnv HTTP_MY_SITE_ROOT “http://localhost/emmay12/” #SetEnv HTTP_MY_SITE_ADMIN “http://localhost/emmay12/admin/” #SetEnv HTTP_MY_SITE_ROOT HTTP_HOST

#RewriteRule /about-us/ http://localhost/emmay12/about_us.php [L,QSA] #RewriteRule ^(.*)/about-us/ localhost/$1/about_us.php [L,QSA] #[L,R=301]

#RewriteCond %{HTTP_HOST} !^localhost/emmay12$ [NC] RewriteRule ^about-us/ about_us.php [L,QSA] RewriteRule ^promotions/ promotions.php [L,QSA] RewriteRule ^act-us/ contactus.php [L,QSA] RewriteRule ^how-to-shop/ howtoshop.php [L,QSA] RewriteRule ^faq/ faq.php [L,QSA] RewriteRule ^Jewellery-Care/ jewelcare.php [L,QSA] RewriteRule ^disclaimer/ disclaimer.php [L,QSA] RewriteRule ^privacy-policy/ policy.php [L,QSA] RewriteRule ^terms-and-conditions/ info.php [L,QSA] RewriteRule ^sitemap/ sitemap.php [L,QSA] RewriteRule ^home/ index.php [L,QSA] RewriteRule ^gift/ gift.php [L,QSA] #RewriteRule ^custom-orders/ customorder.php [L,QSA]

RewriteRule ^referralhistory/ referralhistory.php [L,QSA] RewriteRule ^custom_orders/ custom_orders.php [L,QSA] RewriteRule ^addreferral/ addreferral.php [L,QSA] RewriteRule ^redemptionhistory/ redemptionhistory.php [L,QSA] RewriteRule ^orderstatus_pending/ orderstatus_pending.php [L,QSA] RewriteRule ^editprofile/ editprofile.php [L,QSA] RewriteRule ^earnhostory/ earnhostory.php [L,QSA] RewriteRule ^orderstatus_cancel/ orderstatus_cancel.php [L,QSA] RewriteRule ^goldscheme_status/ goldscheme_status.php [L,QSA] RewriteRule ^changepassword/ changepassword.php [L,QSA] RewriteRule ^pointshistory/ pointshistory.php [L,QSA] RewriteRule ^logout/ logout.php [L,QSA]

RewriteRule ^shopping-cart-blank/$ Copyshoppingcart-blank.php?cart=cart [L,QSA] RewriteRule ^logout/ logout.php [L,QSA] RewriteRule ^login_register/?(.)$ login_register.php?$1 [L,QSA] RewriteRule ^login_register/ login_register.php [L,QSA] RewriteRule ^mywishlist/?(.)$ mywishlist.php?cart=cart&$1 [L,QSA]

RewriteRule ^makebalpayment/?(.*)$ makebalpayment.php?$1 [L,QSA] RewriteRule ^goldtree_payment/ goldtree_payment.php?name=tree [L,QSA] RewriteRule ^goldseed_payment/ goldseed_payment.php?name=seed [L,QSA] RewriteRule ^forgot-password/ forgotpassword.php [L,QSA] RewriteRule ^customsearch/ customsearch.php [L,QSA]

RewriteRule ^goldtree_confirm/ goldtree_confirm.php?name=tree [L,QSA] RewriteRule ^goldseed_confirm/ goldseed_confirm.php?name=seed [L,QSA] RewriteRule ^goldtreefaq/ goldtreefaq.php?name=tree [L,QSA] RewriteRule ^goldseedfaq/ goldseedfaq.php?name=seed [L,QSA] RewriteRule ^new-user/?(.*)$ newuser.php?$1 [L,QSA] RewriteRule ^newuser/ newuser.php [L,QSA]

RewriteRule ^mywishlist/ mywishlist.php?cart=cart [L,QSA] RewriteRule ^thanks-newuser/ thanks_newuser.php [L,QSA] RewriteRule ^watches_size/ watches_size.php [L,QSA] RewriteRule ^orderstatus/ orderstatus.php [L,QSA] RewriteRule ^ring-size/ ring_size.php [L,QSA] RewriteRule ^email-friend/ email_friend.php [L,QSA] RewriteRule ^category/ category.php [L,QSA] RewriteRule ^bill_ship/ bill_ship.php [L,QSA] RewriteRule ^list_testimonial/ list_testimonial.php [L,QSA] RewriteRule ^stonesetting/ stonesetting.php [L,QSA] RewriteRule ^birthstones/ birthstones.php [L,QSA] RewriteRule ^pearl/ pearl.php [L,QSA] RewriteRule ^order_details/?(.)$ order_details.php?$1 [L,QSA] RewriteRule ^shoppingcart/giftvalidation/?(.)$ giftvalidation.php/?$1 [L,QSA] RewriteRule ^shoppingcart/giftvalidation/?(.)$ giftvalidation.php?$1 [L,QSA] RewriteRule ^shoppingcart/(.)/(^.)$ shoppingcart.php?cart=cart&pid=$1 [L,QSA] RewriteRule ^shoppingcart/?(.)$ shoppingcart.php?cart=cart&$1 [L,QSA] RewriteRule ^shoppingcart/ shoppingcart.php?cart=cart [L,QSA]

RewriteRule ^goldcoindetails/?(.*)$ goldcoindetails.php?$1 [L,QSA]

RewriteRule ^solitaire-gemstones/?(.)$ customorder_silver.php?$1 [L,QSA] #RewriteRule ^customorder_silver/ customorder_silver.php [L,QSA] RewriteRule ^pointstoredeem_goldetree/ pointstoredeem_goldetree.php [L,QSA] RewriteRule ^customorder_ringban/?(.)$ customorder_ringban.php?$1 [L,QSA] RewriteRule ^customorder_ringban/ customorder_ringban.php [L,QSA] RewriteRule ^customorder_diamond/ customorder_diamond.php [L,QSA]

RewriteRule ^goldseed_thank/ goldseed_thank.php?name=seed [L,QSA] RewriteRule ^goldtree_thank/ goldtree_thank.php?name=tree [L,QSA]

RewriteRule ^checklogin_status/ checklogin_status.php [L,QSA] RewriteRule ^join-goldtree/ join_goldtree.php?name=tree [L,QSA] RewriteRule ^join-goldseed/ join_goldseed.php?name=seed [L,QSA] RewriteRule ^custorder_details/?(.*)$ custorder_details.php?$1 [L,QSA] RewriteRule ^custorder_details/ custorder_details.php [L,QSA]

RewriteRule ^pay_history_gs/?(.)$ pay_history_gs.php??name=seed&$1 [L,QSA] RewriteRule ^pay_history_gt/?(.)$ pay_history_gt.php??name=tree&$1 [L,QSA] RewriteRule ^gold_tree_billship/?(.)$ gold_tree_billship.php?$1 [L,QSA] RewriteRule ^gold_tree_billship/ gold_tree_billship.php?name=tree [L,QSA] RewriteRule ^gold_seed_billship/?(.)$ gold_seed_billship.php?name=seed&$1 [L,QSA] RewriteRule ^gold_seed_billship/ gold_seed_billship.php?name=seed [L,QSA] RewriteRule ^sapphire/ sapphire.php [L,QSA] RewriteRule ^emerald/ emerald.php [L,QSA] RewriteRule ^ruby/ ruby.php [L,QSA] RewriteRule ^diamond/ diamond.php [L,QSA] RewriteRule ^diamond2/ diamond2.php [L,QSA] RewriteRule ^platinum/ platinum.php [L,QSA] RewriteRule ^gold/ gold.php [L,QSA] RewriteRule ^silver/ silver.php [L,QSA] RewriteRule ^gemmology/ gemmology.php [L,QSA]

RewriteRule ^silver_filigree/ silver_filigree.php [L,QSA] RewriteRule ^bidri/ bidri.php [L,QSA] RewriteRule ^thewa/ thewa.php [L,QSA] RewriteRule ^meenakari/ meenakari.php [L,QSA] RewriteRule ^kundan/ kundan.php [L,QSA] RewriteRule ^jadau/ jadau.php [L,QSA] RewriteRule ^victorian/ victorian.php [L,QSA] RewriteRule ^pointstoredeem/ pointstoredeem.php [L,QSA] RewriteRule ^popuptestimonial/(.)/(.) popuptestimonial.php?id=$1 [L,QSA] RewriteRule ^solitaire-diamond-search/(.)/ diamonds.php?sp=$1&catid=58 [L,QSA] RewriteRule ^solitaire-diamond-search/(.) diamonds.php?sp=$1&catid=58 [L,QSA] RewriteRule ^diamonds/ diamonds.php?catid=58 [L,QSA] RewriteRule ^diamondpair-search/(.)/ diamondspair.php?sp=$1&catid=58 [L,QSA] RewriteRule ^diamondpair-search/(.) diamondspair.php?sp=$1&catid=58 [L,QSA]

RewriteRule ^checkout_ship/ checkout_ship.php [L,QSA] RewriteRule ^payment/ payment.php [L,QSA] RewriteRule ^checkout/ checkout.php [L,QSA] #RewriteRule ^checkout_ship/ checkout_ship.php [L,QSA]

RewriteRule ^ready-to-ship-jewellery/(.)/product-details/?(.)$ productdetails.php?cart=ready&prod_name=$1&$2 [L,QSA]

RewriteRule ^ready-to-ship-jewellery/(.)/?(.)=(.)$ products.php?cart=ready&prod_name=$1&$2=$3 [L,QSA] RewriteRule ^ready-to-ship-jewellery/(.)/ products.php?cart=ready&prod_name=$1 [L,QSA] #RewriteRule ^ready-to-ship-jewellery/(.)/?(.) products.php?prod_name=$1&$2 [L,QSA] RewriteRule ^custom-orders/product-details/(.)/ productdetails.php?catid=2&prod=$1 [L,QSA] RewriteRule ^custom-orders/ customorder.php?catid=2 [L,QSA] RewriteRule ^gold-coins/ goldcoins.php?catid=65 [L,QSA] RewriteRule ^fast-moving/product-details/(.)/ productdetails.php?prod=$1 [L,QSA] RewriteRule ^gold-tree/ goldtree.php?name=tree [L,QSA] RewriteRule ^gold-seed/ goldseed.php?name=seed [L,QSA] RewriteRule ^gift-certificates/ gift.php?catid=1 [L,QSA]

RewriteRule ^featured-items/product-details/(.)/ productdetails.php?prod=$1 [L,QSA] RewriteRule ^featured-items/goldcoin-details/(.)/ goldcoins.php?catid=$1 [L,QSA]

RewriteRule ^(.)/product-details/?(.)$ productdetails.php?$2 [L,QSA] RewriteRule ^jewellery-search/(.*)$ products.php?search=1&$1 [QSA,L]

#RewriteRule ^list_product/?(.*)$ list_product.php?$1 [L,QSA]

RewriteRule ^diamond-details/(.)/ diamond_details.php?pid=$1 [L,QSA] RewriteRule ^product-details/(.)/ productdetails.php?prod=$1 [L,QSA] #to show diamond details

#BUILT YOUR OWN JEWELLARY RewriteRule ^make-your-own-pendent/choose-your-setting/(.)/ custom_pro_item.php?pid=$1&custpid=61&catid=61 [L,QSA] RewriteRule ^make-your-own-ring/choose-your-setting/(.)/ custom_pro_item.php?pid=$1&custpid=63&catid=63 [L,QSA] RewriteRule ^make-your-own-earring/choose-your-setting/(.*)/ custom_pro_item.php?pid=$1&custpid=60&catid=63 [L,QSA]

#to view diamond details of make your own item section diamond details #RewriteRule ^diamond-details/(.)/ diamond_details.php?pid=$1 [L,QSA] RewriteRule ^make-your-own-earring/diamond-details/(.)/?dd=(.*)$ diamond_details.php?catid=60&pid=$1&dd=$2 [L,QSA]

RewriteRule ^make-your-own-jewellery/select-your-diamonds/ diamonds.php?catid=58 [L,QSA] RewriteRule ^make-your-own-pendent/diamond-details/(.)/ diamond_details.php?catid=61&pid=$1 [L,QSA] RewriteRule ^make-your-own-ring/diamond-details/(.)/ diamond_details.php?catid=63&pid=$1 [L,QSA] RewriteRule ^solitaire-diamonds/diamond-details/(.)/ diamond_details.php?catid=60&pid=$1 [L,QSA] RewriteRule ^make-your-own-jewellery/diamond-details/(.)/ diamond_details.php?catid=58&pid=$1 [L,QSA] ##static link of make your own item

RewriteRule ^make-your-own-pendent/select-your-diamonds/ custom_pro_dia.php?catid=61 [L,QSA] RewriteRule ^make-your-own-ring/select-your-diamonds/ custom_pro_dia.php?catid=63 [L,QSA] RewriteRule ^solitaire-diamonds/choose-pairs-for-earring/ custom_pro_dia.php?catid=60 [L,QSA]

RewriteRule ^solitaire-diamonds/ loose_dia.php [L,QSA] RewriteRule ^solitaire-diamonds-details/(.*)/ loose_diamond_details.php?pid=$1 [L,QSA]

RewriteRule ^make-your-own-pendent/choose-your-setting/ custom_pro_item.php?catid=61 [L,QSA] RewriteRule ^make-your-own-ring/choose-your-setting/ custom_pro_item.php?catid=63 [L,QSA] RewriteRule ^make-your-own-earring/choose-your-setting/ custom_pro_item.php?catid=60 [L,QSA]

RewriteRule ^make-your-own-pendent/complete-your-pendent/(.)/ custom_pro_complete.php?catid=61&prod=$1 [L,QSA] RewriteRule ^make-your-own-ring/complete-your-ring/(.)/ custom_pro_complete.php?catid=63&prod=$1 [L,QSA] RewriteRule ^make-your-own-earring/complete-your-earring/(.*)/ custom_pro_complete.php?catid=60&prod=$1 [L,QSA]

RewriteRule ^make-your-own-pendent/complete-your-pendent/ custom_pro_complete.php?catid=61 [L,QSA] RewriteRule ^make-your-own-ring/complete-your-ring/ custom_pro_complete.php?catid=63 [L,QSA] RewriteRule ^make-your-own-earring/complete-your-earring/ custom_pro_complete.php?catid=60 [L,QSA]

#error reporting page RewriteRule ^error404/ 404.php [L,QSA] RewriteRule ^error404 404.php [L,QSA]

Nginx does not support apache .htaccess files. You can however, use this converter to convert your .htaccess into lines to add the the nginx configuration file for your site (found in /etc/nginx/sites-enabled/).

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.