1

I've got a quick situation that I need help with. I'm using nginx and I'm really new to the system, and need a rewrite rule that would rewrite the following: http://website.com/folderName/somePage.php to http://website.com/somePage Please note that somePage will change depending on the file. How can I make it globally recognizable instead of having to make a separate rewrite rule for each page? Can you please fix this code?

I've used the following:

rewrite ^/$ /FolderName/$.php last;

The above line doesnt work and nginx fails to restart

Any help would be great!

Thanks so much in advance. :)

Black Sheep
  • 6,604
  • 7
  • 30
  • 51
George
  • 301
  • 3
  • 18
  • Sorry about the ambiguous question - I need rewrite code! thanks! – George May 29 '14 at 02:37
  • You know that SO do not provide code? We are here to help if you have an issue...anyway... have a look here: http://stackoverflow.com/questions/4329316/how-to-write-a-url-rewrite-in-nginx – Black Sheep May 29 '14 at 02:44

2 Answers2

1

Try this:

rewrite ^/([A-Za-z]+)$ /folderName/$1.php last;
Black Sheep
  • 6,604
  • 7
  • 30
  • 51
0

You can try adding it to try_files, of course you can reorder this according to your priorities.

try_files $uri $uri/ $uri.php /index.php;
Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89