Code On
Code On

Reputation: 233

Laravel 5.2 : only route '/' works in windows iis server

today I had a problem when I try to access my project route in windows iis server.

my application url is : demo.example.com/testing/

the root routing is working '/', but not with the other.

for example, if I try to clicking menu with '/home/' route, the url will be like demo.example.com/home' , the 'testing' is gone somehow.

PS : I already remove the 'public' folder with moving all of files in public folder outside, and moving the other files into new folder.

Route example:

Route::get('/', 'frontend\frontController@index');

Route::get('/login', 'frontend\frontController@login');

Thanks for helping !

Upvotes: 2

Views: 3823

Answers (4)

EACUAMBA
EACUAMBA

Reputation: 611

I solved this error by downloading URL Rewrite 2.1 and having this in web.config.

Image of Web Platform where eyou cand download the assets.

O meu ficheiro web.config

    <!--
    Rewrites requires Microsoft URL Rewrite Module for IIS
    Download: https://www.iis.net/downloads/microsoft/url-rewrite
    Debug Help: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Upvotes: 1

Boris Lutskovsky
Boris Lutskovsky

Reputation: 561

it comes down to URL rewrites. I had the exact same issue, and I needed to add a rule in web.config:

<rule name="routes" stopProcessing="true">
                  <match url="^(.*)$" ignoreCase="false" />
                  <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />                     
                  </conditions>
                  <action type="Rewrite" url="public/index.php/{R:1}" />

                </rule>

from this blog post: https://laracasts.com/discuss/channels/servers/iis-8-laravel-webconfig

Upvotes: 2

Rizky Arlin
Rizky Arlin

Reputation: 383

Can you access the login page by demo.example.com/testing/public/index.php?/login

If yes, the problem probably in your server configuration or .htaccess

I've just encountered the same problem, for me enabling mod_rewrite for apache2 fix it.

You should probably read:

https://laravel.com/docs/5.0/configuration#pretty-urls

Can't route properly in Laravel

Can't access URL in Laravel routes

The last thing, You shouldn't do this thing below.

PS : I already remove the 'public' folder with moving all of files in public folder outside, and moving the other files into new folder.

Stop messing with the folder structure. Do not do things you don't know!

Upvotes: 0

Frnak
Frnak

Reputation: 6802

You are not supossed to place laravel in a subfolder. Your subdomain should directly point to the application without any further subfolders since Laravel will use absolute paths to navigate to your routes. e.g.

Route::get('home', ...)

will always navigate to yourdomain.com/home even though it actually maches yourdomain.com/laravel/home unless you make a lot of changes to your setup.

Upvotes: 0

Related Questions