Please help me to convert this .htaccess for nginx conf PLEASE HELP ME .
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1
RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=profile&id=$1
RewriteRule ^m_profile/([0-9]+)/([A-Za-z0-9-]+)/?$ mobile.php?page=profile&id=$1
RewriteRule ^chat/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=chat&id=$1
RewriteRule ^search/([A-Za-z0-9-]+)/?$ index.php?page=logout
RewriteRule ^search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?page=logout
and this is my default block server nginx.conf
server {
listen xxx.xxx.xxx.xxx:80;
server_name domain.com www.domain.com;
root /home/myuser/web/domain.com/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/domain.com.log combined;
access_log /var/log/nginx/domains/domain.com.bytes bytes;
error_log /var/log/nginx/domains/domain.com.error.log error;
location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9007;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/myuser/web/domain.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/myuser/web/domain.com/stats/;
include /home/myuser/conf/web/domain.com.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/myuser/conf/web/nginx.domain.com.conf*;
}
help me how to make the htaccess complete in nginx conf and work on my server. I don’t understand anything about this. please help me and I will be very grateful to you
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!
Hello. Please help me to convert my .htaccess for NGINX. I’ll be very thankful.
IndexIgnore *
RewriteEngine On
#RewriteBase /
RewriteCond %{HTTP_HOST} ^letsgo-africa.com [NC]
RewriteRule ^(.*)$ https://www.letsgo-africa.com/$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.letsgo-africa.com/$1 [L,R=301]
#RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
#RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
<Files *.tpl>
Deny from all
</Files>
<Files *.inc>
Deny from all
</Files>
RewriteRule ^aboutus index.php?file=c-page&iPageId=1
RewriteRule ^privacy-policy index.php?file=c-page&iPageId=2
RewriteRule ^terms-conditions index.php?file=c-page&iPageId=3
RewriteRule ^Partners index.php?file=c-page&iPageId=4
RewriteRule ^contactus index.php?file=c-contactus
RewriteRule ^faqs index.php?file=c-faqs
RewriteRule ^offer-ride index.php?file=c-offer_ride
RewriteRule ^offer-ride-duplicate index.php?file=m-offer_ride_duplicate
RewriteRule ^sign-in index.php?file=c-login
RewriteRule ^sign-up index.php?file=c-registration
RewriteRule ^my-account index.php?file=m-dashboard
RewriteRule ^logout index.php?file=m-logout
RewriteRule ^codeofconduct index.php?file=c-page&iPageId=9
RewriteRule ^how-we-works index.php?file=c-page&iPageId=5
RewriteRule ^blabla-code-conduct index.php?file=c-page&iPageId=6
RewriteRule ^cookie-policy index.php?file=c-page&iPageId=12
RewriteRule ^find-ride index.php?file=c-find_ride
RewriteRule ^search-car-sharing-result index.php?file=c-ride_list
RewriteRule ^page/(.*)/(.*) index.php?file=c-page&iPageId=$1&title=$2
RewriteRule ^journey/(.*)/(.*)/(.*) index.php?file=c-ride_detail&id=$1&from=$2&to=$3
RewriteRule ^car-edit-form/(.*) index.php?file=m-car_form&iMemberCarId=$1
RewriteRule ^car-add-form index.php?file=m-car_form
RewriteRule ^car-details index.php?file=m-car_details
RewriteRule ^Member-Verification index.php?file=m-verification
RewriteRule ^Member-Phone-Varification index.php?file=m-phone_varification
RewriteRule ^Change-Password index.php?file=m-changepassword
RewriteRule ^Notification index.php?file=m-notification
RewriteRule ^car-preferences index.php?file=m-preferences
RewriteRule ^leave-Rating index.php?file=m-leaverating
#RewriteRule ^Member-Rating/(.*) index.php?file=m-memberrating&iMemberToId=$1
RewriteRule ^Member-Rating index.php?file=m-memberrating
RewriteRule ^Receive-Rating index.php?file=m-receiverating
RewriteRule ^Rating-Given index.php?file=m-ratinggiven
RewriteRule ^my-bookings index.php?file=m-mybooking
RewriteRule ^received-messages index.php?file=m-received_messages
RewriteRule ^sent-messages index.php?file=m-sent_messages
#RewriteRule ^message-details/(.*)$ index.php?file=m-messagedtl&iMessageId=$1
RewriteRule ^message-details/(.*)/(.*)$ index.php?file=m-messagedtl&from=$1&iMessageId=$2
RewriteRule ^booking-cancellation/(.*)$ index.php?file=m-booking_cancelation_form&id=$1
RewriteRule ^personal-information index.php?file=m-edit_profile
RewriteRule ^profile-photo index.php?file=m-profile_photo
RewriteRule ^Member-Stories-Form index.php?file=m-member_addstory
RewriteRule ^Member-Stories index.php?file=m-member_stories
RewriteRule ^List-Rides-Offer index.php?file=m-list_rides_offer
RewriteRule ^Rides-Edit-Form/(.*) index.php?file=m-ride_form&iRideId=$1
RewriteRule ^Email-Alerts index.php?file=m-member_alert
RewriteRule ^archived-messages index.php?file=m-archived_messages
RewriteRule ^Page-Not-Found index.php?file=c-404_error
ErrorDocument 404 https://www.letsgo-africa.com/Page-Not-Found
ErrorDocument 505 /index.php?file=c-page&iPageId=17&title=$1
RewriteRule ^refund-cancellation-policy index.php?file=c-page&iPageId=10
RewriteRule ^Ride-Detail/(.*)/(.*)/(.*)$ index.php?file=c-ride_details&from=home&id=$1&dt=$2&ret=$3
RewriteRule ^Public-Profile/(.*)$ index.php?file=c-user_profile&iMemberId=$1
RewriteRule ^Money-Detail/Available index.php?file=m-money_detail&type=available
RewriteRule ^Money-Detail/History index.php?file=m-money_detail&type=history
RewriteRule ^Delete-Account index.php?file=m-delete_account
RewriteRule ^Add-Car index.php?file=m-car_form
#####################################################################
<filesMatch "\.(css|jpg|png|gif|js)$">
Header set Cache-Control "max-age=29030400, public"
</filesMatch>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary Yes
mod_gzip_command_version '/mod_gzip_status'
mod_gzip_min_http 1000
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 512000
mod_gzip_maximum_inmem_size 60000
mod_gzip_handle_methods GET POST
mod_gzip_temp_dir /tmp
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.pl$
mod_gzip_item_include file \.rb$
mod_gzip_item_include file \.py$
mod_gzip_item_include file \.cgi$
mod_gzip_item_include file \.css$
mod_gzip_item_include file \.js$
mod_gzip_item_include mime ^application/javascript$
mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include handler ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_include handler ^application/x-httpd-php
mod_gzip_item_exclude mime ^image/.*
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Media: images, video, audio
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# CSS and JavaScript
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
</IfModule>
Header unset ETag
FileETag None
#####################################################################
My nginx.conf
server {
listen XX.XX.XX.XX:80;
server_name letsgo-africa.com www.letsgo-africa.com;
root /home/letsgo-africa/web/letsgo-africa.com/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/letsgo-africa.com.log combined;
access_log /var/log/nginx/domains/letsgo-africa.com.bytes bytes;
error_log /var/log/nginx/domains/letsgo-africa.com.error.log error;
location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9004;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/letsgo-africa/web/letsgo-africa.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/letsgo-africa/web/letsgo-africa.com/stats/;
include /home/letsgo-africa/conf/web/letsgo-africa.com.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/letsgo-africa/conf/web/nginx.letsgo-africa.com.conf*;
}
# nginx configuration
location / {
if ($script_filename !~ "-d"){
rewrite ^/([A-Za-z0-9-]+)/?$ /index.php?page=$1;
}
}
location /profile {
rewrite ^/profile/([0-9]+)/([A-Za-z0-9-]+)/?$ /index.php?page=profile&id=$1;
}
location /m_profile {
rewrite ^/m_profile/([0-9]+)/([A-Za-z0-9-]+)/?$ /mobile.php?page=profile&id=$1;
}
location /chat {
rewrite ^/chat/([0-9]+)/([A-Za-z0-9-]+)/?$ /index.php?page=chat&id=$1;
}
location /search {
rewrite ^/search/([A-Za-z0-9-]+)/?$ /index.php?page=logout;
rewrite ^/search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?page=logout;
}
I converted your .htaccess file into nginx. Try to register these parameters, I am sure that everything should work correctly. On the Internet there are different services for converting .htaccess to nginx. If something does not work, try to use these services. For example, owners of different sites contact me for help. If I don’t know something, I search for information on Google and find answers. If I don’t know how to do a homework, I order it on grademiners. I recommend first searching for a solution in Google. Try to apply the tips in practice. And if something does not work out, find an expert on freelancing, they will quickly help to solve your problem.
Thank you very much . I have also tried using winginx and implementing the nginx.conf server block and it doesn’t seem to work. but I will try it using the default template nginx-phpfpm on the vestacp feature. hopefully this is resolved. thanks again beautiful sister
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.