Welcome! Log In Create A New Profile

Advanced

Convert .htaccess to nginx rules

Posted by ThanksDude 
ThanksDude
Convert .htaccess to nginx rules
January 09, 2018 02:50PM
hey guys

I tried the tools and it didn't worked for me.
can u guys pls help me convert this to a nginx rules?


RewriteEngine On

#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Options +FollowSymLinks
Options -Indexes

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule . index.php [L,QSA]



# Performace optimization

# BEGIN Compress text files
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml
application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml
application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript
application/x-javascript application/json
AddOutputFilterByType DEFLATE application/x-font-ttf
application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
</ifModule>
# END Compress text files

# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 31536000 seconds"
ExpiresByType image/jpeg "access plus 31536000 seconds"
ExpiresByType image/png "access plus 31536000 seconds"
ExpiresByType image/gif "access plus 31536000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 31536000
seconds"
ExpiresByType text/css "access plus 31536000 seconds"
ExpiresByType text/javascript "access plus 31536000 seconds"
ExpiresByType application/javascript "access plus 31536000 seconds"
ExpiresByType application/x-javascript "access plus 31536000 seconds"
</ifModule>
# END Expire headers

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch ".(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch ".(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch ".(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>

<filesMatch ".(woff|woff2|ttf|otf|eot)$">
Header set Cache-Control "max-age=31536000 private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278046,278046#msg-278046

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Anoop Alias
Re: Convert .htaccess to nginx rules
January 09, 2018 03:30PM
try_files $uri $uri/ /index.php;

should work

On Tue, Jan 9, 2018 at 7:10 PM, ThanksDude <[email protected]>
wrote:

> hey guys
>
> I tried the tools and it didn't worked for me.
> can u guys pls help me convert this to a nginx rules?
>
>
> RewriteEngine On
>
> #RewriteCond %{HTTPS} off
> #RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
>
> #RewriteCond %{HTTP_HOST} !^www\.
> #RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
>
> Options +FollowSymLinks
> Options -Indexes
>
> RewriteCond %{SCRIPT_FILENAME} !-d
> RewriteCond %{SCRIPT_FILENAME} !-f
> RewriteRule . index.php [L,QSA]
>
>
>
> # Performace optimization
>
> # BEGIN Compress text files
> <ifModule mod_deflate.c>
> AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
> AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml
> application/xml
> AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml
> application/atom+xml
> AddOutputFilterByType DEFLATE text/javascript application/javascript
> application/x-javascript application/json
> AddOutputFilterByType DEFLATE application/x-font-ttf
> application/x-font-otf
> AddOutputFilterByType DEFLATE font/truetype font/opentype
> </ifModule>
> # END Compress text files
>
> # BEGIN Expire headers
> <ifModule mod_expires.c>
> ExpiresActive On
> ExpiresDefault "access plus 5 seconds"
> ExpiresByType image/x-icon "access plus 31536000 seconds"
> ExpiresByType image/jpeg "access plus 31536000 seconds"
> ExpiresByType image/png "access plus 31536000 seconds"
> ExpiresByType image/gif "access plus 31536000 seconds"
> ExpiresByType application/x-shockwave-flash "access plus 31536000
> seconds"
> ExpiresByType text/css "access plus 31536000 seconds"
> ExpiresByType text/javascript "access plus 31536000 seconds"
> ExpiresByType application/javascript "access plus 31536000 seconds"
> ExpiresByType application/x-javascript "access plus 31536000 seconds"
> </ifModule>
> # END Expire headers
>
> # BEGIN Cache-Control Headers
> <ifModule mod_headers.c>
> <filesMatch ".(ico|jpe?g|png|gif|swf)$">
> Header set Cache-Control "public"
> </filesMatch>
> <filesMatch ".(css)$">
> Header set Cache-Control "public"
> </filesMatch>
> <filesMatch ".(js)$">
> Header set Cache-Control "private"
> </filesMatch>
> <filesMatch ".(x?html?|php)$">
> Header set Cache-Control "private, must-revalidate"
> </filesMatch>
>
> <filesMatch ".(woff|woff2|ttf|otf|eot)$">
> Header set Cache-Control "max-age=31536000 private, must-revalidate"
> </filesMatch>
> </ifModule>
> # END Cache-Control Headers
>
> Posted at Nginx Forum: https://forum.nginx.org/read.
> php?2,278046,278046#msg-278046
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



--
*Anoop P Alias*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
ThanksDude
Re: Convert .htaccess to nginx rules
January 10, 2018 04:00AM
Thanks @Anoop Alias
However I tried it and unfortunately it didn't worked.

What reason can it be?
I'm running latest nginx (1.13.8)

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278046,278060#msg-278060

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login