2013-02-22 35 views
11

Khuôn khổ Laravel4 đi kèm với quy tắc mặc định .htaccess để tạo các url đẹp.Laravel .htaccess ghi đè quy tắc hội tụ vào IIS

Quy tắc là điều này.

<IfModule mod_rewrite.c> 
    Options -MultiViews 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

Câu hỏi: Điều gì tương đương với IIS ??

Trả lời

8

Bạn có thể sử dụng import Apache rules feature để chuyển đổi quy tắc Apache thành IIS.

Trong trường hợp của bạn, nó sẽ đi như:

import

Hoặc trong file web.config:

<rule name="Imported Rule 1" stopProcessing="true"> 
    <match url="^" ignoreCase="false" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="index.php" /> 
</rule> 
+0

Rất hữu ích, cảm ơn. –

+0

@jcadiz cách thêm mã này và nơi công khai hoặc trong htacess. Hãy giúp tôi –

2

Có một vài phần bổ sung mà có giá trị đưa vào web của bạn. config file

Đoạn mã dưới đây cho phép bạn tạo các bộ điều khiển hoàn toàn bằng cách sử dụng các động từ HTTP PUT và DELETE bổ sung, và cho phép s cho các trang lỗi tùy chỉnh laravel để được hiển thị khi bạn đang remotley gỡ lỗi máy chủ:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Laravel4" 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" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
     <handlers> 
      <remove name="PHP53_via_FastCGI" /> 
      <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST,PUT,DELETE" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" requireAccess="Script" /> 
     </handlers> 
     <httpErrors errorMode="Detailed" /> 
    </system.webServer> 
</configuration> 
4

này làm việc cho tôi, nhờ Oli Folkerd:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Laravel4" 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" appendQueryString="true" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 
Các vấn đề liên quan