I have a perfectly working web application developed using Laravel 4.2. This app has been tested 100% and approved by testing team. Now I have uploaded this to Windows Server 2008 R8 running IIS7. I have also set up a domain and the home page works fine.
But there is a problem with url rewrite. For example,
http://domain.com //This works along with css and js loaded properly
Now the error part
http://domain.com/register //Doesn't work
http://domain.com/index.php/register //This works
So I tried a method. In the IIS domain for domain.com I imported URL Rules form the .htaccess found in the public folder of Laravel. The import was successful.
Now when I access,
http://domain.com //This works but without CSS and JS
http://domain.com/register //Now this works but without CSS and JS
The .htaccess code I used was
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule . index.php [L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Why is it that the website works only if index.php
in between domain.com
and register
Any piece or advise or a working method is appreciated.
Thank you.
You need an IIS-compatible rewrite (URLRewrite) in web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteRequestsToPublic">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="public/{R:0}" />
</rule>
<rule name="Laravel Rewrite" 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="public/index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.