Welcome Guest, Not a member yet? Register   Sign In
URI Rewrite and IIS
#1

[eluser]Benjo[/eluser]
Hello,

I'm in the process of migrating a CI application from Apache to IIS and I don't seem to get the IIS equivalent of .htaccess to work. Both are intranets and I would like to be able to go from http://mysite.domain.edu/index.php/home to http://mysite.domain.edu/home.

I'm currently trying to use a solution from HELICON (http://www.helicontech.com/isapi_rewrite/doc/). Here are the contents of the .htaccess and httpd.conf respectively:

.htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|jqueryui|tinyMCE|css|images|robots\.txt)
RewriteRule ^(.*)$ /PHC/index.php/$1 [L]

--------------

httpd.conf:
RewriteEngine on
RewriteRule ^([^?]+)\index.php$ $1 [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME}index.php -f
RewriteRule (.*) $1index.php

As I mentioned above, the .htaccess works fine on Apache, but the httpd.conf version does not work on IIS.

I greatly appreciate any help I can get.
#2

[eluser]cideveloper[/eluser]
This is the one I use on one of my IIS boxes. Im sure you will have to tweak it, but it works perfectly for me.

Code:
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.73

RewriteEngine on

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]


RewriteRule ^/(assets|images|fonts|css|files|js|wp-*|sitemap\.xml)(.*)$ /$1$2 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]
#3

[eluser]Benjo[/eluser]
Thanks for the quick feedback. I have 2 questions, if you don't mind:

1) where on your server is your httpd.conf located? Mine is located in "C:\Program Files\Helicon\ISAPI_Rewrite3".

2) could you briefly explain what the following lines of your code do?

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
#4

[eluser]cideveloper[/eluser]
1) Yup, Mine is there too

2) If your site can be accessed with www.sitename.com and sitename.com it is a good idea to redirect one version to another to avoid possible duplicate content penalty from the search engines. its just to 301 redirect everything non www to the corresponding www address

I got it from the help file with ISAPI_Rewrite
#5

[eluser]Benjo[/eluser]
Thanks again! Still no luck at the moment...

Assuming my current intranet's URL on IIS is http://app.name.edu/index.php/welcome and I'm trying to rewrite it to http://app.name.edu/welcome, below are the two solutions I've tried without success:

RewriteEngine on

RewriteCond URL ^/(?!jqueryui|tinyMCE|css|images|index\.php|robots\.txt).*
RewriteRule ^(.*)$ /index.php/$1 [L]

############

RewriteEngine on

RewriteRule ^/jqueryui/(.*)$ /jqueryui/$1 [L]
RewriteRule ^/tinyMCE/(.*)$ /tinyMCE/$1 [L]
RewriteRule ^/css/(.*)$ /css/$1 [L]
RewriteRule ^/images/(.*)$ /images/$1 [L]
RewriteRule ^/robots\.txt/(.*)$ /robots\.txt/$1 [L]

RewriteCond %{HTTP_HOST} ^(?Smile?app.name\.edu$
RewriteRule ^(.*)$ /index.php/$1


Any suggestions?




Theme © iAndrew 2016 - Forum software by © MyBB