Jump to content

I can't enable the Friendly URL option when using nginx, why?


Recommended Posts

Hi All,

 

I am using nginx as my webserver.

 

I have set-up rewrite rules to match the default apache ones and they work if I type a URL to test the rules myself.

 

But! I can't get the entire shop to use friendly URLs because I can't enable the Friendly URLs option in Preferences > SEO & URLs.

 

When I choose 'Yes' and click save, it forces the option back to 'No' and says that:

 

URL rewriting (mod_rewrite) is not active on your server or it is not possible to check your server configuration. If you want to use Friendly URLs you must activate this mod.

 

Obviously nginx does not use mod_rewrite, so how can I turn this on?

 

How can I force this to 'Yes'? Because nginx does support Friendly URLs...

 

Thanks!

Link to comment
Share on other sites

OK, I figured this one out...

 

Not sure if it's a bug or my server config. is causing this.

 

When using the APC caching system and having the cache enabled, some settings in the Back-Office wouldn't show as changed. That's why even when I selected 'Yes' for Friendly URLs, as soon as I refreshed the page it would snap back to 'No'.

 

I turned off the APC cache in the Back Office, change the settings I needed to and they changed correctly...

 

I suppose the server is caching some of the back-office database? Maybe? Anyone have any ideas?

Link to comment
Share on other sites

  • 2 years later...

I you need make same configurations on nginx Directives for url rewrite, above follow the code example:

 

location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
 
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
       rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
       rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
       rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last;
       rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
       rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last;
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...