404 page not found on all pages except home page

Asif Ullah 0 Reputation points
2023-10-06T12:58:36.4933333+00:00

I have deployed my web app designed in codeighter 3. currently i am facing issue with url.
my home page url is working fine which is https://doktorconnect.azurewebsites.net/

but when i click any other url like https://doktorconnect.azurewebsites.net/profile this shows 404 page not found.

but if i add index.php in url, then it works. https://doktorconnect.azurewebsites.net/profile

i want my url to work without index.php

this is my web.config code:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Remove index.php" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{URL}" pattern="^/index\.php" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Microsoft Security | Intune | Configuration Manager | Other
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,178 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,226 Reputation points Moderator
    2023-10-10T20:38:47.87+00:00

    Hi @Asif Ullah thanks for the question.

    You can usually resolve this issue by modifying your web.config file and CodeIgniter’s config.php file as shared on this similar SO thread. Try the following these steps:

    1. In your web.config file, replace your current rule with this one:
    <rule name="Imported Rule 1" stopProcessing="true">
        <match url="^(.*)$" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        </conditions>
        <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
    </rule>
    
    1. In your CodeIgniter’s config.php file, change the url_protocol to 'PATH_INFO':
    $config['url_protocol'] = 'PATH_INFO';
    

    This will tell the URL rewrite module to use the rewritten URI instead of the original URL

    Also you can also check your Apache access log and error log to see where the browser request is being routed<sup>.</sup> You can also activate logging in CodeIgniter by setting $config['log_threshold'] = 2; Don’t forget to set appropriate permissions to the system/logs directory so Apache can write log files to it.

    Best,

    Grace


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.