Welcome Guest, Not a member yet? Register   Sign In
IIS support
#1

hi
i would like to suggest that codeigniter as it come configured with .htaccess for Apache, to be the same with web.config for IIS, instead of searching web of how to configure it
Reply
#2

(07-25-2016, 05:51 PM)ibraheem_ghazi Wrote: hi
i would like to suggest that codeigniter as it come configured with .htaccess for Apache, to be the same with web.config for IIS, instead of searching web of how to configure it

If you could provide one, we'll be happy to. It's been years since I've used IIS and never got good at it's config settings. In other words - please submit a pull request.
Reply
#3

(This post was last modified: 07-25-2016, 08:29 PM by ibraheem_ghazi.)

(07-25-2016, 07:56 PM)kilishan Wrote: If you could provide one, we'll be happy to. It's been years since I've used IIS and never got good at it's config settings. In other words - please submit a pull request.
here is the file i attached to each project i uploaded and it's work perfect on CI3
at the bottom i added woff2 mime manually its not required
Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
  <!--<customErrors mode="Off"/>-->
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
    <system.webServer>
      <security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483647"/>
    </requestFiltering>
    </security>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" 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?url={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
        <staticContent>
    <remove fileExtension=".woff2" />
    <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
  </staticContent>
  

    </system.webServer>

</configuration>

btw as we are in same topic i would suggest for htaccess this file which does not require the ReWrite Base

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Reply
#4

Have you checked the repo ... there is an Apache .htaccess in the public folder ... https://github.com/bcit-ci/CodeIgniter4/.../.htaccess

Perhaps we need some installation instructions for setting up similar capability for NGINX, IIS & other popular servers.

@ibraheem_ghazi You provided a config file, I presume for IIS. What instructions would accompany it, eg where should this file go, how does IIS get configured for virtual hosting, what about DB config, etc.
Reply
#5

(07-25-2016, 10:00 PM)ciadmin Wrote: Have you checked the repo ... there is an Apache .htaccess in the public folder ... https://github.com/bcit-ci/CodeIgniter4/.../.htaccess

Perhaps we need some installation instructions for setting up similar capability for NGINX, IIS & other popular servers.

@ibraheem_ghazi You provided a config file, I presume for IIS. What instructions would accompany it, eg where should this file go, how does IIS get configured for virtual hosting, what about DB config, etc.
of course i have checked and read it but the difference that this file is not dependent on the Rewrite base which mean if you put it in sub folder or move it you don't need to re-edit .htaccess file and set the Rewrite base

for IIS nothing new just install iis with php and mysql then in IIS create a new website then set the assigned ip,port,host and path then in host if needed for localhost add the host you put
web.config file will be along side with .htaccess file

here is a video that demonstrate how to create a new website on localhost
https://www.youtube.com/watch?v=LMWW12FGoHM
Reply
#6

(This post was last modified: 06-06-2019, 09:08 AM by mightyted.)

HI

Is it safe to assume that for the Web.config file to work as provided, one would require the URL Rewrite Mod to be installed on your IIS server?
Reply
#7

Ok, I know this thread is as old as the hills and am unsure if there is another thread with the steps needed to Import mod_rewrite rules to IIS as the search function here currently isn't working for me. But I thought I would add a quick how-to for those who are not familliar with transforming Apache mod_rewrite rules from .htaccess to an IIS web.config file.

Step 1
Install the URL Rewrite module for IIS (Suggest installing this as part of a clean IIS (Web Server) Install, IF IIS is already installed, but without the URL Rewrite Module, use the Web platform Installer from Microsoft to install the module)

Step 2
Make a backup of the .htaccess file found in the /public folder

Step 3
Make a new version of .htaccess and place it in the /public folder with only these rules included:

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

Step 4
In IIS Manager, in the left column, navigate to the site you wish to apply these rules too.
Ie. SERVER-NAME->Sites->Configured-site

Step 5
In the IIS section of the settings, double click the URL Rewrite Module

Step 6
    A) In the right hand column, click on "Import Rules"
    B) On the "Import mod_rewrite rules" page in the configuration file box, click the ... button and navigate to the .htaccess file you created in Step 3 and click the Import button.
    C) In the "Rewrite Rules Box", you should see your rules from the .htaccess file and in the Summary below that, you should see Summary: 3 of 3 rules(s) were converted successfully. 0 rule(s) were not converted.
    D) In the right hand column, click Apply and your rules will be written to the web.config file, and your done.

    Note: If there is an error, the Apply button will be shaded and unclickable.

Hope this helps out.
Reply
#8
Thumbs Up 
(This post was last modified: 09-01-2021, 02:17 AM by timexpeachtree. Edit Reason: Closing Tags JS Sample code )

(05-31-2021, 07:00 AM)stlake2011 Wrote: Ok, I know this thread is as old as the hills and am unsure if there is another thread with the steps needed to Import mod_rewrite rules to IIS as the search function here currently isn't working for me. But I thought I would add a quick how-to for those who are not familliar with transforming Apache mod_rewrite rules from .htaccess to an IIS web.config file.

Step 1
Install the URL Rewrite module for IIS (Suggest installing this as part of a clean IIS (Web Server) Install, IF IIS is already installed, but without the URL Rewrite Module, use the Web platform Installer from Microsoft to install the module)

Step 2
Make a backup of the .htaccess file found in the /public folder

Step 3
Make a new version of .htaccess and place it in the /public folder with only these rules included:

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

Step 4
In IIS Manager, in the left column, navigate to the site you wish to apply these rules too.
Ie. SERVER-NAME->Sites->Configured-site

Step 5
In the IIS section of the settings, double click the URL Rewrite Module

Step 6
    A) In the right hand column, click on "Import Rules"
    B) On the "Import mod_rewrite rules" page in the configuration file box, click the ... button and navigate to the .htaccess file you created in Step 3 and click the Import button.
    C) In the "Rewrite Rules Box", you should see your rules from the .htaccess file and in the Summary below that, you should see Summary: 3 of 3 rules(s) were converted successfully. 0 rule(s) were not converted.
    D) In the right hand column, click Apply and your rules will be written to the web.config file, and your done.

    Note: If there is an error, the Apply button will be shaded and unclickable.

Hope this helps out.

Thanks we have found when hosting our applications as internal Application in IIS Website Sub-folder, Idea  we have to pass the base_url() to the Javascript for API Calls in JS to work correctly to the subfolder (i.e. As the Rewrite Base rule commented out in .htaccess file i haven't found a similar equivalent to do in IIS URL Rewrite module).

Code:
<script>
$(document).ready(function (){
mybaseurl = <?= "'".base_url()."'" ?>+'';
});
</script>
And prefix it to all AJAX/API Calls
Code:
$.ajax({
        method: 'POST',
        url: mybaseurl + '/ajaxtry/store',
        data: data,
        success: function(response) {
        }
  });
Reply




Theme © iAndrew 2016 - Forum software by © MyBB