преобразование правил переписывания Apache в IIS web.config - PullRequest
0 голосов
/ 30 августа 2018

Спасибо, но этот ответ был решен. Я смог успешно изменить правила, поэтому мне не нужны дальнейшие указания.


Новичок в FuelPHP и унаследовал приложение, использующее топливо. Я пытаюсь преобразовать .htaccess в web.config с помощью импорта через перезапись URL-адреса, но возникают ошибки, при которых определенные правила не преобразуются.

.htaccess файл

   # Multiple Environment config, set this to development, staging or production
    # SetEnv FUEL_ENV production

    RewriteBase /bbb/

    <IfModule mod_rewrite.c>

      # Make sure directory listing is disabled
      Options +FollowSymLinks -Indexes
      RewriteEngine on

      # NOTICE: If you get a 404 play with combinations of the following commented out lines
      #AllowOverride All
      #RewriteBase /wherever/fuel/is

      # Restrict your site to only one domain
      # !important USE ONLY ONE OPTION

      # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
      #RewriteCond %{HTTPS} !=on
      #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

      # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
      #RewriteCond %{HTTPS} !=on
      #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
      #RewriteCond %{HTTP_HOST} (.+)$ [NC]
      #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

      #Remove index.php from URL
      #RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
      #RewriteCond %{THE_REQUEST}               ^[^/]*/index\.php [NC]
      #RewriteRule ^index\.php(.*)$         $1 [R=301,NS,L]

      # Send request via index.php (again, not if its a real file or folder)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d

      # deal with php5-cgi first
      <IfModule mod_fcgid.c>
         RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
      </IfModule>

      <IfModule !mod_fcgid.c>

        # for normal Apache installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        # for Apache FGCI installations
        # note '?' removed to prevent url appearing in Input::get()
        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [QSA,L]
        </IfModule>

    </IfModule>

XML преобразованных правил

<rewrite>
  <!--This directive was not converted because it is not supported by IIS: RewriteBase /bbb/.-->
  <!--This directive was not converted because it is not supported by IIS: RewriteBase /wherever/fuel/is.-->
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <!--# Multiple Environment config, set this to development, staging or production-->
        <!--# SetEnv FUEL_ENV production-->
        <add input="{HTTPS}" pattern="^on$" ignoreCase="false" negate="true" />
        <add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="http://{C:1}/{R:1}" />
    </rule>
    <rule name="Imported Rule 2" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="^on$" ignoreCase="false" negate="true" />
        <add input="{HTTP_HOST}" pattern="^www\..+$" negate="true" />
        <add input="{HTTP_HOST}" pattern="(.+)$" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="http://www.{C:1}/{R:1}" />
    </rule>
    <!--The rule cannot be converted into an equivalent IIS format because of unsupported flags: NS-->
    <rule name="Imported Rule 4" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <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="index.php?/{R:1}" appendQueryString="true" />
    </rule>
    <rule name="Imported Rule 5" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <action type="Rewrite" url="index.php/{R:1}" />
    </rule>
    <rule name="Imported Rule 6" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

Я попытался удалить 3 неконвертированных правила (и поиграл с комментированием других правил в .htaccess), но в итоге я получаю ошибку PDOException «Не удалось найти драйвер» каждый раз. Может ли кто-нибудь помочь с этим переписать (Извинения, так как этот вопрос очень похож на многие, которые были заданы в стеке ранее).

Заранее спасибо

...