I'm making a website where the host is running PHP as CGI which is new to me.<br /><br />I just uploaded the first test and ran into some problems.<br /><br />I've set up <!-- w --><a class="postlink" href="http://www.example.com/feed/news.xml">www.example.com/feed/news.xml</a><!-- w --> to point to <!-- w --><a class="postlink" href="http://www.example.com/feed.php?feed=news">www.example.com/feed.php?feed=news</a><!-- w --><br />On my local system that runs PHP style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /> what gives?<!--content-->
<!--quoteo(post=5126:date=May 16 2007, 07:27 PM:name=Thomas Thomassen)--><div class='quotetop'>QUOTE(Thomas Thomassen @ May 16 2007, 07:27 PM) [snapback]5126[/snapback]</div><div class='quotemain'><!--quotec-->I just found out that the site by default, without any .htaccess files, redirects URLs like <!-- w --><a class="postlink" href="http://www.example.com/test/">www.example.com/test/</a><!-- w --> into <!-- w --><a class="postlink" href="http://www.example.com/test.php">www.example.com/test.php</a><!-- w --><br /><br />So when I request <!-- w --><a class="postlink" href="http://www.example.com/news/2007/05/title-text/">www.example.com/news/2007/05/title-text/</a><!-- w --> it points to <!-- w --><a class="postlink" href="http://www.example.com/news.php">www.example.com/news.php</a><!-- w --> but NONE of the arguments are being passed style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /> what gives?<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />the super globals cant pass, as the URL needs to be bengribbin.com/news.php?ben=cool&&me=helpful<br /><br />If the URL is rewritten, I am not sure it can GET the info from the URL<!--content-->
mod rewrite doesn't affect the $_GET variables, you can still use them in the way you want as long as your mod rewrite rules are correctly written.<br /><br />Wildo<!--content-->
I wondered the same before Gold_Killer set me straight. Unless it was you wildo.<!--content-->
the mod_rewrite rules works locally, but not target="_blank">http://testsite.desktopx.info/<br /><br />(and I don't get why it keep redirecting <!-- m --><a class="postlink" href="http://testsite.desktopx.info/">http://testsite.desktopx.info/</a><!-- m --> to <!-- m --><a class="postlink" href="http://testsite.desktopx.info/default.html">http://testsite.desktopx.info/default.html</a><!-- m --> ... grrr)<!--content-->
I think I'm getting closer. Seem to be something called Content Negotiation. <!-- m --><a class="postlink" href="http://www.the-art-of-web.com/system/rewrite/1/">http://www.the-art-of-web.com/system/rewrite/1/</a><!-- m --><br /><br />Gotto find a way to disable it.<!--content-->
Got it working somewhat. But there are things I don't understand:<br /><br />For some reason this worked on my local test server, but not on the host:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--># News rewrite<br />RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php<br />RewriteRule ^news/(\d\d\d\d)/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php?year=$1<br />RewriteRule ^news/(\d\d\d\d)/(\d\d)/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php?year=$1&month=$2<br />RewriteRule ^news/(\d\d\d\d)/(\d\d)/([a-zA-Z0-9_\-]+)/$ /news.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br />I had to use this on the live server:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php<br />RewriteRule ^news/([0-9]{4})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php?year=$1<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php?year=$1&month=$2<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/([a-zA-Z0-9_\-]+)/$ news2.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br /><br /><br />The news2.php bit was so I could work around the Content Negotiation.<br />And that's another thing. I tried placing the news.php file in a folder named 'php' so the rules would look like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php<br />RewriteRule ^news/([0-9]{4})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php?year=$1<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php?year=$1&month=$2<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/([a-zA-Z0-9_\-]+)/$ php/news.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br />But that resulted in a 404. The PHP folder permissions are 755.<br />At the top of the .htaccess I set RewriteBase /<!--content-->
<!--quoteo(post=5126:date=May 16 2007, 07:27 PM:name=Thomas Thomassen)--><div class='quotetop'>QUOTE(Thomas Thomassen @ May 16 2007, 07:27 PM) [snapback]5126[/snapback]</div><div class='quotemain'><!--quotec-->I just found out that the site by default, without any .htaccess files, redirects URLs like <!-- w --><a class="postlink" href="http://www.example.com/test/">www.example.com/test/</a><!-- w --> into <!-- w --><a class="postlink" href="http://www.example.com/test.php">www.example.com/test.php</a><!-- w --><br /><br />So when I request <!-- w --><a class="postlink" href="http://www.example.com/news/2007/05/title-text/">www.example.com/news/2007/05/title-text/</a><!-- w --> it points to <!-- w --><a class="postlink" href="http://www.example.com/news.php">www.example.com/news.php</a><!-- w --> but NONE of the arguments are being passed style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /> what gives?<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />the super globals cant pass, as the URL needs to be bengribbin.com/news.php?ben=cool&&me=helpful<br /><br />If the URL is rewritten, I am not sure it can GET the info from the URL<!--content-->
mod rewrite doesn't affect the $_GET variables, you can still use them in the way you want as long as your mod rewrite rules are correctly written.<br /><br />Wildo<!--content-->
I wondered the same before Gold_Killer set me straight. Unless it was you wildo.<!--content-->
the mod_rewrite rules works locally, but not target="_blank">http://testsite.desktopx.info/<br /><br />(and I don't get why it keep redirecting <!-- m --><a class="postlink" href="http://testsite.desktopx.info/">http://testsite.desktopx.info/</a><!-- m --> to <!-- m --><a class="postlink" href="http://testsite.desktopx.info/default.html">http://testsite.desktopx.info/default.html</a><!-- m --> ... grrr)<!--content-->
I think I'm getting closer. Seem to be something called Content Negotiation. <!-- m --><a class="postlink" href="http://www.the-art-of-web.com/system/rewrite/1/">http://www.the-art-of-web.com/system/rewrite/1/</a><!-- m --><br /><br />Gotto find a way to disable it.<!--content-->
Got it working somewhat. But there are things I don't understand:<br /><br />For some reason this worked on my local test server, but not on the host:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--># News rewrite<br />RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php<br />RewriteRule ^news/(\d\d\d\d)/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php?year=$1<br />RewriteRule ^news/(\d\d\d\d)/(\d\d)/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /news.php?year=$1&month=$2<br />RewriteRule ^news/(\d\d\d\d)/(\d\d)/([a-zA-Z0-9_\-]+)/$ /news.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br />I had to use this on the live server:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php<br />RewriteRule ^news/([0-9]{4})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php?year=$1<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â news2.php?year=$1&month=$2<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/([a-zA-Z0-9_\-]+)/$ news2.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br /><br /><br />The news2.php bit was so I could work around the Content Negotiation.<br />And that's another thing. I tried placing the news.php file in a folder named 'php' so the rules would look like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteRule ^news/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php<br />RewriteRule ^news/([0-9]{4})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php?year=$1<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/$Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â php/news.php?year=$1&month=$2<br />RewriteRule ^news/([0-9]{4})/([0-9]{2})/([a-zA-Z0-9_\-]+)/$ php/news.php?year=$1&month=$2&title=$3<!--c2--></div><!--ec2--><br /><br />But that resulted in a 404. The PHP folder permissions are 755.<br />At the top of the .htaccess I set RewriteBase /<!--content-->