I\'m converting my mediawiki site to use nginx as a frontend for static files with apache on the backend for php. I\'ve gotten everything working so far except for when I vi
I found help in the nginx irc chat.
Basically what I needed to do was use a return instead of rewrite. So I changed this:
location = / {
rewrite "^$" /wiki/Main_Page;
}
to this:
location = / {
return 301 http://www.example.com/wiki/Main_Page;
}
Here's my solution:
if ($uri = '/'){
rewrite ^/(.*)$ http://example.com/wiki/Main_Page permanent;
}
I prefer to use:
location = / {
return 301 http://$host/wiki/Main_Page;
}
The answer you used is a redirect, making you skip the /
location to a /wiki
location, You can try this instead
location = / {
rewrite ^ /w/index.php?title=Main_Page&$args last;
}
This should server the Main_Page for the /
URI
Using rewrite rules in location section like this:
location = / {
rewrite "^.*$" /wiki/Main_Page break;
}
Pay attention "break" here. Means break out the rewrite cycle.
If this page is located in backend server, here should use proxy_pass.
Add rewrite
directive to server
section:
server {
...
rewrite ^/$ /wiki/Main_Page
...
}