PDA

View Full Version : [SOLVED] .htaccess vs web.config



stooshbunutu
April 3rd, 2011, 04:12 PM
I realise this isn't really an ubuntu issue, but I need a web.config file to run php in a .xml file. I use
AddType application/x-httpd-php .xml in a .htaccess file on my linux server, but the guy I'm doing this for insists on doze sadly. Anyone know how I can do this with web.config?

nshiell
April 3rd, 2011, 11:02 PM
Why do u need to run PHP in an XML script?
can't you alter the .htaccess to redirect a URL to the XML file to a normal PHP file?

---OR---

Statically generate the XML file and save it to the file system for the user to access?

Much better iMO

stooshbunutu
April 3rd, 2011, 11:45 PM
I need the php to run because the content of the xml is generate from a database. Hence I can't just make a static page either.

I can't use the .htaccess because the stupid windows server won't read it, needs to be web.config :(

SeijiSensei
April 3rd, 2011, 11:57 PM
Does Apache for Windows support a .htaccess equivalent? Never used it myself, but if I had to use Windows as a web server, I certainly wouldn't want to use anything other than Apache.

slavik
April 4th, 2011, 07:33 AM
I need the php to run because the content of the xml is generate from a database. Hence I can't just make a static page either.

I can't use the .htaccess because the stupid windows server won't read it, needs to be web.config :(
wait, what?

1. how is xml generated from db?
2. how is that xml valid php?
3. why not change the last 3 letters from xml to php?
4. why is windows a requirement?
5. this is a horrible set up from the information available thus far.

stooshbunutu
April 4th, 2011, 07:54 AM
1. how is xml generated from db?
2. how is that xml valid php?
3. why not change the last 3 letters from xml to php?
4. why is windows a requirement?
5. this is a horrible set up from the information available thus far.

xml is generated from the db via php looping through the results of a query and echoing the results. It's essentially a basic rss feed, which is why it needs to be xml. I've done it on my linux server here: (http://cycleblog.mstrutt.co.uk/rss.xml).

Windows is a requirement because the server for this website is a windows server. I'm not happy with it being one, but that's the situation I am in.

AlexC_
April 4th, 2011, 09:52 AM
xml is generated from the db via php looping through the results of a query and echoing the results. It's essentially a basic rss feed, which is why it needs to be xml. I've done it on my linux server here: (http://cycleblog.mstrutt.co.uk/rss.xml).

Windows is a requirement because the server for this website is a windows server. I'm not happy with it being one, but that's the situation I am in.

Your problem is not because of Windows, but because you're using IIS of which "web.config" is a similar thing to ".htaccess" (an Apache feature). You can always run Apache on Windows, however I see that isn't going to happen.

Parsing XML files through PHP is just stupid and shouldn't have been done from the start. You're best off at this stage to simply create a rewrite rule for "rss.xml" to "rss.php", e.g.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="XML>
<match url="^rss\.xml$" ignoreCase="true" />
<action type="Rewrite" url="rss.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

stooshbunutu
April 6th, 2011, 07:56 AM
Your problem is not because of Windows, but because you're using IIS of which "web.config" is a similar thing to ".htaccess" (an Apache feature). You can always run Apache on Windows, however I see that isn't going to happen.

Parsing XML files through PHP is just stupid and shouldn't have been done from the start. You're best off at this stage to simply create a rewrite rule for "rss.xml" to "rss.php", e.g.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="XML">
<match url="^rss\.xml$" ignoreCase="true" />
<action type="Rewrite" url="rss.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Hey, thanks very much for the solution, I have just implemented it and it works a treat :)