0

Example: http://phpdiscussionboard.azurewebsites.net/?/dashboards/dashboard

How can I get rid of the ? in the URL pattern for my PHP app I've deployed via Azure? With it my routing doesn't work. When I manually remove the ? and send the URL request it works fine, but with the ? in the URL pattern it messes up my whole app.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55

2 Answers2

0

Considering you have to replace the first instance of a ?, you can use the following function:

function replaceFirst( $url, $to, $by ) {

    $url = explode( "/", $url );
    $arr = array();

    for( $i = 0; $i < count($url); $i++ ) {

        $current = $url[ $i ];
        if( $current == $to ) {
            if ( $by == "" ) { continue; }
            else { $current = $by; }
        } else if( $current == null ) { continue; }

        array_push( $arr, $current );

    }

    return implode( $arr, "/" );

}

And you can use it like this: replaceFirst("http://phpdiscussionboard.azurewebsites.net/?/dashboards/dashboard", "?", "") which will give you a value like: http:/phpdiscussionboard.azurewebsites.net/dashboards/dashboard. You can fix the minor error of the http:/ there, but this should be the logic.

I am really sorry if this is not the answer you're looking for, but the question you've asked is rather vague.

weirdpanda
  • 2,521
  • 1
  • 20
  • 31
-1

As Azure Web Apps uses IIS to host PHP applications, and we can leverage web.config to manage our site.

I found the similar requirement with you on stackoverflow, and I leverage this answer, convert the .htaccess content to web.config, then I test on Azure Web app, it works fine. But I haven't modified the settings of base_url and index_page in the config.php.

So create a file named web.confg with the following content in the root directory of your application: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.webServer> <rewrite> <rules> <rule name="rule 1R" stopProcessing="true"> <match url="^(.*)$" /> <action type="Rewrite" url="/index.php/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration> And click the RESTART button at the bottom nav bar of your site manage portal.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Hi Gary, I modified my web.config to look like that, and my config.php base_url is = to ' ' and my index_page is equal to ' ' as well. When i hit login , the url it displays is: http://phpdiscussionboard.azurewebsites.net/?/dashboard when i want it to display http://phpdiscussionboard.azurewebsites.net/dashboard only. when i manually change the url to just dashboard, i am taken to the dashboard and can see that it did in fact log me in. – Theodore Rollin Anderson Nov 13 '15 at 14:44
  • 1
    I figured it out. In config.php I turned enable query strings to false. – Theodore Rollin Anderson Nov 13 '15 at 14:50