To answer in more general terms your question of understanding;
I think I must have misunderstood something - can anyone explain?
Putting aside SEF for the moment, turn it off if you will.
Any page displayed from Joomla is going to have an ?option=com_something
as part of the URL as this part of URL Query tells Joomla what Component is to be displayed. For example displaying articles, Blogs or Lists, it will be ?option=com_content
, for the Contact pages it will be ?option=com_contact
and any number of 3rd party Component extensions will have their ?option=com_nameofcomponent
Therefore using something like AMM to exclude any links that contain ?option
is really not the solution here as all URL's are going to contain an option
in some form.
The index.php is the entry point for any link to start Joomla, this file is what is executed to for every request for Joomla from the browser and has nothing to do with whether it is a homepage or any other page, it is always there to tell the browser which file will start Joomla. To not display the index.php in the URL you need to select 'Use URL Rewriting' as part of using the SEF URL's, index.php can not be removed/hidden as part of the non-SEF URL.
What tells Joomla that a page is the Homepage is where the yellow house icon is set against a menu item in Joomla, see image. Internally Joomla processing will be saying if you haven't told me to display a specific page or menu item then display the default page, the one displaying the yellow icon.
There is nothing in the URL to distinguish a page as being the Homepage or not, however the current menu id is displayed as &itemid=nnn
. Therefore if you know that the Homepage menu id is 101, as in my image above, then &itemid=101 will appear in the URL and you can respond to that, but again there is nothing in the URL that says you are on the Homepage.
A key component of Joomla called 'The Router' plays an important part in that it takes the Query from the incoming URL, that is everything to the right of the first '?', and breaks it down to determine what Joomla is to do with the request. This determines the Component/Extension(option=com_something), the page to displayed(view=fred), the command or action to be taken(task=barney), the record in the database to be used(id=), the page layout to use(&layout=wilma) and so on including the menu to be used(&itemid=). The option
is the only one that appears in all URL's and the rest will be dependant on the component being called.
http://mydomian/index.php?option=com_content&view=featured&Itemid=101
The second part of 'The Routers' job is when Joomla is preparing a page to be displayed it will go through all the links, internal ones, and do things like add the 'https://mydomain' to the front of each link and make sure they are correctly formed so that when selected on the page the URL provided will get processed, parsed, correctly by the incoming part of 'The Router'.
When your turn on SEF that is telling 'The Router' that when preparing the links on a page to change them from the non-sef format to the SEF format, that is converting them from
https://mydomain/index.php?option=com_content&view=category&layout=blog&id=9&Itemid=102
to
https://mydomain/index.php/products
And conversely when 'The Router' receives the incoming SEF formed URL Query it will convert the URL Query back to the non-SEF URL before processing the URL to determine what action Joomla is to take.
To answer your question in the comments of @itoctopus's answer, no you don't have to go through and change every occurrence of the index.php/?option. With SEF and URL Rewriting turned on the Router will do that dynamically when each page is being built.
Between earlier versions of Joomla 3 and Joomla 4 there was some major changes to the way 'The Router' works that can cause some strange behaviour with older Joomla 3 style links coming into a Joomla 4 site, such as those stored by Google and other search engines.
Therefore it is best to get the Joomla 4 site behaving the way you want it to, using SEF URL Queries, and ignore the older Joomla 3 syle incoming links. Eventually search engines will update the older links they have stored.
If you want to deal more actively with the older links then you can look at the Redirect extension of Joomla or an equivalent 3rd party extension.
As @Itoctopus has pointed out the older style links that don't have an &itemid=
will use the default menu id, the menu specified as the Homepage, and thus your module reappears on pages where it is not wanted.