|
Next: What is the worst College Web Site you have seen?
|
| Author |
Message |
External

Since: May 30, 2006 Posts: 452
|
(Msg. 1) Posted: Mon Aug 14, 2006 12:30 pm
Post subject: mod_rewrite help Archived from groups: alt>www>webmaster (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: May 30, 2006 Posts: 452
|
(Msg. 2) Posted: Mon Aug 14, 2006 1:26 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: May 30, 2006 Posts: 452
|
(Msg. 3) Posted: Mon Aug 14, 2006 1:32 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: May 30, 2006 Posts: 452
|
(Msg. 4) Posted: Mon Aug 14, 2006 1:45 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
GreyWyvern <spam.DeleteThis@greywyvern.com> wrote in
news:op.tead4rqcsl6xfd@news.nas.net:
> And lo, Karl Groves didst speak in alt.www.webmaster:
>
>> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>>
>>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>>
>>>> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>>>>
>>>>> www.example.com/?id=foo
>>>>> to:
>>>>> www.example.com/foo
>>>>>
>>>>> RewriteEngine On
>>>>>
>>>>> RewriteCond %{QUERY_STRING} ^id=(.*)$
>>>>> RewriteRule ^$ /%1? [R=301]
>>>>
>>>> Didna work. Got a 404
>>>
>>> I tested it on my own server before posting it here, and it WFM. Do
>>> you get a 404 when you go to www.example.com/foo directly?
>>
>> Yeah.
>> What's weird is now, if I go to www.example.com/?id=foo it redirect
> s me
>> to
>> www.example.com/foo
>
> I'm confused then, because I thought that's what you wanted.
>
Well, now the PHP script isn't liking the lack of the ID in the URL.
--
Karl Groves
www.karlcore.com >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: May 08, 2004 Posts: 952
|
(Msg. 5) Posted: Mon Aug 14, 2006 2:03 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: May 30, 2006 Posts: 452
|
(Msg. 6) Posted: Mon Aug 14, 2006 2:22 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
GreyWyvern <spam RemoveThis @greywyvern.com> wrote in
news:op.teafmfnqsl6xfd@news.nas.net:
> And lo, Karl Groves didst speak in alt.www.webmaster:
>> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>>> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>>>>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>>>>> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>>>>>>
>>>>>>> www.example.com/?id=foo
>>>>>>> to:
>>>>>>> www.example.com/foo
>>>>>>>
>>>>>>> RewriteEngine On
>>>>>>>
>>>>>>> RewriteCond %{QUERY_STRING} ^id=(.*)$
>>>>>>> RewriteRule ^$ /%1? [R=301]
>>>>>>
>>>>>> Didna work. Got a 404
>>>>>
>>>>> I tested it on my own server before posting it here, and it WFM.
>>>>> D
> o
>>>>> you get a 404 when you go to www.example.com/foo directly?
>>>>
>>>> Yeah.
>>>> What's weird is now, if I go to www.example.com/?id=foo it redire
> ct
>>> s me
>>>> to
>>>> www.example.com/foo
>>>
>>> I'm confused then, because I thought that's what you wanted.
>>
>> Well, now the PHP script isn't liking the lack of the ID in the URL.
>
> You mean the PHP script is still looking for the id in the query
> string? Perhaps we have things backwards then and really you wish to
> *rewrite* www.example.com/foo to www.example.com/?id=foo
>
> In that case, we'd do:
>
> RewriteEngine On
>
> RewriteRule ^([^/]+)$ /?id=$1 [L]
>
>
Now www.example.com/foo gives an HTTP 500 error
--
Karl Groves
www.karlcore.com >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: May 08, 2004 Posts: 952
|
(Msg. 7) Posted: Mon Aug 14, 2006 2:32 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
And lo, Karl Groves didst speak in alt.www.webmaster:
> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>
>> www.example.com/?id=foo
>> to:
>> www.example.com/foo
>>
>> RewriteEngine On
>>
>> RewriteCond %{QUERY_STRING} ^id=(.*)$
>> RewriteRule ^$ /%1? [R=301]
>
> Didna work. Got a 404
I tested it on my own server before posting it here, and it WFM. Do you
get a 404 when you go to www.example.com/foo directly?
>> [1] Begging your pardon for calling you Shirley.
>
> I've been called worse
I'll bet
Grey
--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#search - Orca Search: Full-featured
spider and site-search engine >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: May 08, 2004 Posts: 952
|
(Msg. 8) Posted: Mon Aug 14, 2006 2:39 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
And lo, Karl Groves didst speak in alt.www.webmaster:
> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>
>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>
>>> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>>>
>>>> www.example.com/?id=foo
>>>> to:
>>>> www.example.com/foo
>>>>
>>>> RewriteEngine On
>>>>
>>>> RewriteCond %{QUERY_STRING} ^id=(.*)$
>>>> RewriteRule ^$ /%1? [R=301]
>>>
>>> Didna work. Got a 404
>>
>> I tested it on my own server before posting it here, and it WFM. Do
>> you get a 404 when you go to www.example.com/foo directly?
>
> Yeah.
> What's weird is now, if I go to www.example.com/?id=foo it redirects me
> to
> www.example.com/foo
I'm confused then, because I thought that's what you wanted.
Grey
--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#search - Orca Search: Full-featured
spider and site-search engine >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: May 08, 2004 Posts: 952
|
(Msg. 9) Posted: Mon Aug 14, 2006 3:12 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
And lo, Karl Groves didst speak in alt.www.webmaster:
> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>>>> And lo, Karl Groves didst speak in alt.www.webmaster:
>>>>> GreyWyvern <spam.DeleteThis@greywyvern.com> wrote:
>>>>>
>>>>>> www.example.com/?id=foo
>>>>>> to:
>>>>>> www.example.com/foo
>>>>>>
>>>>>> RewriteEngine On
>>>>>>
>>>>>> RewriteCond %{QUERY_STRING} ^id=(.*)$
>>>>>> RewriteRule ^$ /%1? [R=301]
>>>>>
>>>>> Didna work. Got a 404
>>>>
>>>> I tested it on my own server before posting it here, and it WFM. Do
>>>> you get a 404 when you go to www.example.com/foo directly?
>>>
>>> Yeah.
>>> What's weird is now, if I go to www.example.com/?id=foo it redirect
>> s me
>>> to
>>> www.example.com/foo
>>
>> I'm confused then, because I thought that's what you wanted.
>
> Well, now the PHP script isn't liking the lack of the ID in the URL.
You mean the PHP script is still looking for the id in the query string?
Perhaps we have things backwards then and really you wish to *rewrite*
www.example.com/foo to www.example.com/?id=foo
In that case, we'd do:
RewriteEngine On
RewriteRule ^([^/]+)$ /?id=$1 [L]
In cases where you have enabled extension mapping, you might grab the file
extension text too if a file named foo.php or foo.html (etc.) actually
exists. You can bypass that using:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule ^.*$ /?id=%1 [L]
Grey
--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#search - Orca Search: Full-featured
spider and site-search engine >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: May 08, 2004 Posts: 952
|
(Msg. 10) Posted: Mon Aug 14, 2006 3:37 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
And lo, Karl Groves didst speak in alt.www.webmaster:
> GreyWyvern <spam RemoveThis @greywyvern.com> wrote:
>
>> You mean the PHP script is still looking for the id in the query
>> string? Perhaps we have things backwards then and really you wish to
>> *rewrite* www.example.com/foo to www.example.com/?id=foo
>>
>> In that case, we'd do:
>>
>> RewriteEngine On
>>
>> RewriteRule ^([^/]+)$ /?id=$1 [L]
>
> Now www.example.com/foo gives an HTTP 500 error
All I can say is that it WFM  Perhaps you should specify what file you
wish to rewrite to:
RewriteEngine On
RewriteRule ^([^/]+)$ index.php?id=$1 [L]
Grey
--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollary that nothing is ridiculous.
- http://www.greywyvern.com/orca#search - Orca Search: Full-featured
spider and site-search engine >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: Sep 19, 2003 Posts: 3499
|
(Msg. 11) Posted: Mon Aug 14, 2006 7:42 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Jan 25, 2005 Posts: 235
|
(Msg. 12) Posted: Mon Aug 14, 2006 8:43 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Mon, 14 Aug 2006 13:45:43 -0500, Karl Groves put finger to keyboard
and typed:
>Well, now the PHP script isn't liking the lack of the ID in the URL.
How are you parsing it?
This is a script snippet that I use when I need a page to work either
with "traditional" GET variables or with URL parsing:
<?
$id_get = $_GET['id']; // www.example.com/?id=foo will yield 'foo'
$URL_split = explode("/", $_SERVER['SCRIPT_URL']);
$id_url = $URL_split[1]; // www.example.com/foo will yield 'foo'
if ($id_get) { $id = $id_get; }
elseif ($id_url) { $id = $id_url ; }
else { $id = "mydefaultvalue"; }
?>
and then work from there with your value of $id.
Mark
--
Please give me one! http://www.pleasegivemeone.com >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |
External

Since: Sep 14, 2004 Posts: 2384
|
(Msg. 13) Posted: Mon Aug 14, 2006 9:59 pm
Post subject: Re: mod_rewrite help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Karl Groves wrote
> Well, now the PHP script isn't liking the lack of the ID in the URL.
I'm guessing (half guessing, we discussed this recently) that you want
to lose "id=" in your URLs to keep (amongst others) Google sweet.
I was in a similar position, and got around it thus:
Change:
www.example.com/?id=foo
to:
www.example.com/?banana=foo
Then in the script that handles it, put this (or similar as appropriate)
near the top:
if(isset($banana)){$id = $banana;}
The script still gets its "id" values, those of banana.
--
Charles Sweeney
http://CharlesSweeney.com >> Stay informed about: mod_rewrite help |
|
| Back to top |
|
 |  |