Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess and Windows Hosting
#1
Currently using GetSimple on a Windows host. However, the generation of .htaccess files can cause a problem (every time I go on the health check page for example). This is because some IIS extensions recognise these files, for the purpose of password protecting folders.

To work round this, I have had to do a check every time a .htaccess file may be generated.
Code:
if(PHP_OS != 'WINNT') { ... htaccess creation ... }

Due to the fact that not having .htaccess files prevents "pretty url's", I have worked around this through the use of a web.config file. Protecting folders should work in IIS 6 (Windows 2003), however the url rewriting requires IIS 7 (Windows 2008) and the URL Rewrite add-on.
Code:
<?xml version="1.0"?>
<configuration>
    <location path="data">
        <system.web>
            <authorization>
                <deny users="*" />
            </authorization>
        </system.web>
    </location>
    <location path="data/uploads">
        <system.web>
            <authorization>
                <allow users="*" />
            </authorization>
        </system.web>
    </location>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="getsimple">
                <match url="/?([A-Za-z0-9-]+)/?$"/>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                </conditions>
                <action type="Rewrite" url="index.php?id={R:1}"/>
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>

Would it be possible for GetSimple to be changed to prevent the creation of .htaccess files on a Windows host (the side effect of this will be no folder protecting or url rewriting on Apache Windows, but I've not seen a Web Host offer this and it make no real sense to do so). Without this check, I have to trawl through the source to make sure these files aren't created.
-- Sam
Reply
#2
Correct me if I’m wrong, but you’re talking about web servers running IIS, not Windows hosts in general. This is also why using PHP_OS would mess things up.

I don’t have access to Windows right now but I assume Windows running Apache will return the same PHP_OS string as Windows running IIS. Many web developers use Windows based machines but develop for Linux servers, this means they run Apache. Just because PHP_OS tells us we’re on Windows doesn’t mean we’re on IIS.

We might be able to check for the SERVER_SOFTWARE info of $_SERVER but I have no idea how much that one varies between versions of server software.

Another problem is that some .htaccess files are not created at all. They are in the folder structure as soon as you extract GetSimple from its download.

With all these problems (and with non of us core guys being on IIS) I wouldn’t count on official IIS support in the core anytime soon.

Hope this makes the problems clear. Of course, if you or anyone else can come up with good solutions we will gladly implement it. It’s open-source for a reason!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
Hmm...wouldn't a simple php script do the thing ?
It could just go through whole GS directory tree, and delete all .htaccess file after installation.
Addons: blue business theme, Online Visitors, Notepad
Reply
#4
I'm aware that PHP_OS only reports the operating system, hence the mention of Apache Windows. I'm a user of XAMPP myself. SERVER_SOFTWARE would be a better check though, just need to check if it contains the string 'Microsoft-IIS' (or just IIS would be fine). Windows Server just appends the version (Microsoft-IIS/6.0, Microsoft-IIS/7.0 etc)

For the times when Windows Server 2008+ is not used, there is always urlrewriting.net. However, it requires that the host has wildcard application mapping set up to allow all requests to pass through the ASP.NET filter (which is probably unlikely).

Other than health-check.php, what else creates .htaccess files?
-- Sam
Reply
#5
SamWM Wrote:Other than health-check.php, what else creates .htaccess files?
You could search the SVN build to figure this out.

As I said:
Zegnåt Wrote:[…] some .htaccess files are not created at all. They are in the folder structure as soon as you extract GetSimple from its download.
Actually, I can’t find anything that creates a .htaccess file. All of them are copied from other places. health-check.php does not create the files either, it copies them from /admin/inc/tmp/.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#6
I would also like to use the Fancy URL feature, however I am using Windows Hosting Running IIS 7 on a shared hosting account with GoDaddy.

I am hosting many websites on this one hosting account, but this is the only php site. So I cannot just switch my account to unix hosting

The health check page is green all the way done, showing successful installations of everything. However, soon as I check the fancy url, I get 404 errors.
Reply
#7
@SamWM thanks for posting the web.config code... it worked perfect on my GS 3.0 install.

I have been hosting on WIN/IIS 7 for about a year now and LOVE IT!!! We do mostly Joomla! development on it and use a web.config file to do the URL rewrites.

Anyway, I realize I am about a year late here but I wanted to say thank you!
Reply
#8
I am also interested in finding a way to make this work on IIS6/Win2K3/PHP5.2.12. Yeah, I know, it's 2016... go figure. 
Reply




Users browsing this thread: 1 Guest(s)