1
votes

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. :)

2
Sorry about the ambiguous question - I need rewrite code! thanks! - George
You know that SO do not provide code? We are here to help if you have an issue...anyway... have a look here: stackoverflow.com/questions/4329316/… - Black Sheep

2 Answers

1
votes

Try this:

rewrite ^/([A-Za-z]+)$ /folderName/$1.php last;
0
votes

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;