Help With Rss And Htaccess

liunx

Guest
i'm back, with more problems, and your help is greatly appreciated. here's the problem:<br /><br />i was trying to set up a rss feed for my blog. i know there are probably scripts/programs that generate rss feeds, but since it's just an xml file, i thought i'd write a little script myself. however, on my blog, the url for each file would look something like this:<br /><!--coloro:red--><span style="color:red"><!--/coloro-->....../blog/entry.php?id=23&view=simple<!--colorc--></span><!--/colorc--><br />so i put the following line in the xml file<br /><!--coloro:red--><span style="color:red"><!--/coloro--><link>....../blog/entry.php?id=23&view=simple</link><!--colorc--></span><!--/colorc--><br />and the browser tells me that it's malformed. it works only if it's something like<br /><!--coloro:red--><span style="color:red"><!--/coloro--><link>....../blog/entry.php?id=23</link><!--colorc--></span><!--/colorc--><br />but i need the 'view=simple' bit in the url, so my first question, then, is <b>is there a way to have 'entry.php?id=23&view=simple' as a link in the xml file?</b> i'm using rss version 2.0 by the way.<br /><br />anyway, i looked a bit on the net and couldn't work out a solution, so i went to plan b. instead of<br /><!--coloro:red--><span style="color:red"><!--/coloro-->....../blog/entry.php?id=23&view=simple<!--colorc--></span><!--/colorc--><br />i'll change the url to the following<br /><!--coloro:red--><span style="color:red"><!--/coloro-->....../blog/entry/23/simple/<!--colorc--></span><!--/colorc--><br />and have .htaccess redirect me. this way i can put the link in the rss feed at least. so i went to the .htaccess file in my <b>public_html</b> dir, and added the following lines<br /><!--coloro:red--><span style="color:red"><!--/coloro-->RewriteEngine On<br />RewriteRule entry/(.+)/(.+)(/?)$ entry.php?id=$1&view=$2<!--colorc--></span><!--/colorc--><br />however, it didn't work. so i created a directory <b>public_html/blog/entry</b>. then i created a new .htaccess file there, and put the same two lines in that file. it didn't work again. and the error says that 'The requested URL /blog/entry/17/simple/ was not found on this server.'<br />so what am i doing wrong? <b>is there something wrong with the directive in the .htaccess file, or i should've put it somewhere else?</b><br /><br />this seems implausible, but maybe servers has to be restarted for the change to take effect? on my linux at home i need to restart the web server if i change something in http.conf, but surely if the .htaccess is already there in the public_html dir there's no need to restart?<br /><br />anyway, solution to just one problem would be sufficient. thanks for your help!<!--content-->
<!--QuoteBegin-rebel+Jul 3 2005, 06:54 AM--><div class='quotetop'>QUOTE(rebel @ Jul 3 2005, 06:54 AM)</div><div class='quotemain'><!--QuoteEBegin-->so i put the following line in the xml file<br /><!--coloro:red--><span style="color:red"><!--/coloro--><link>....../blog/entry.php?id=23&view=simple</link><!--colorc--></span><!--/colorc--><br />and the browser tells me that it's malformed. it works only if it's something like<br /><!--coloro:red--><span style="color:red"><!--/coloro--><link>....../blog/entry.php?id=23</link><!--colorc--></span><!--/colorc--><br />but i need the 'view=simple' bit in the url, so my first question, then, is <b>is there a way to have 'entry.php?id=23&view=simple' as a link in the xml file?</b><br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=138237"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br />There are certain characters that need to be encoded if they appear within XML data. You have one of those characters in your <link> element data and it's not encoded, which is why your browser complains about your feed being 'malformed'.<br /><br />These are the characters that need to be encoded (replaced with its corresponding HTML entity) in XML data, and what they need to be encoded as:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->& - &<br />< - <<br />> - ><br />' - &apos;<br />" - "<!--c2--></div><!--ec2--><br /><br />In your case, you have an unencoded '&' in the URL. If you replace the '&' with '<!--fonto:Courier--><span style="font-family:Courier"><!--/fonto-->&<!--fontc--></span><!--/fontc-->' in your <link> elements:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><link>....../blog/entry.php?id=23&view=simple</link><!--c2--></div><!--ec2--><br />...your browser should accept your feed as 'well-formed'.<br /><br />Hope this helps...<!--content-->
thanks david, that worked right away! i thought the second '=' was the problem because when i tried to open the rss file in my firefox it said that error was with the second '=', so i didn't really look at the '&' at all. it all makes sense now. great!<br /><br />(ok i know i said i only need to get one of the two problems solved, but just out of curiosity, can anyone tell me what's wrong with the .htaccess redirect?)<br /><br />cheers..<!--content-->
If you're going to put the mod_rewrite lines in the .htaccess file that's in your /public_html directory, you'd need to modify your rule so it's working with the full URL that mod_rewrite is going to see. You probably should also have a RewriteBase directive to tell mod_rewrite what directory its working in:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteEngine On<br />RewriteBase /<br />RewriteRule blog/entry/(.+)/(.+)(/?)$ blog/entry.php?id=$1&view=$2<!--c2--></div><!--ec2--><br />You don't have to use this, but this rule is a little more specific and perhaps perform a bit better matching:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteRule blog/entry/([0-9]+)/([^/]+)/?$ blog/entry.php?id=$1&view=$2<!--c2--></div><!--ec2--><br />You could also put the mod_rewrite directives in an .htaccess file in your /public_html/blog directory, changing the RewriteBase and RewriteRule to reflect the directory they're operating in:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteEngine On<br />RewriteBase /blog<br />RewriteRule entry/(.+)/(.+)(/?)$ entry.php?id=$1&view=$2<!--c2--></div><!--ec2--><br />You shouldn't need a /public_html/blog/entry directory at all.<br /><br />Hope this helps...<!--content-->
ok, i will give that a try<br />thanks for all your help david<br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/notworthy.gif" style="vertical-align:middle" emoid=":notworthy:" border="0" alt="notworthy.gif" /><!--content-->
 
Top