I’m not sure if it’s the correct area, but I want to share this information as I couldn’t find it anywhere.
If, like me, you where struggling to find out how to remove the index.php from the url of your custom webapp, what I mean, in other words, or by example is that:
Instead of https://mycustomwebapp.com/index.php/pageI want to obtain https://mycustomwebapp.com/page.
Here’s the solution
Go to /etc/nginx/conf.d/your_custom_webapp_url, open your_custom_webapp_url.conf.
Then under:
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
Add this:
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?q=$1 last;
}
Be aware, I’m not an expert, to me it just works, but I’m sure if it’s optimal, or safe.
@Toshiwoz
You don’t need to remove index.php from nginx configuration.
If you have to use an app under webapp which don’t need php. Go to /var/www/mywebapp/www/ and remove the index.html. Put your created page as index.html and it will run as you wanted.
If you want a php app then you need to put the php app in /var/www/mywebapp/www. The app should index.php in it.
Thanks for the question, I have updated the post in order to be clearer.
I don’t want someone accidentally remove the index.php file from whatever they’re using… LOL…
LOL, no, sorry, that’s not what I meant…
I want to remove it from the url, I was struggling to do that because I thought I had to modify the .htaccess file, but that had no effect.