Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17414 > unrolled thread

page redirecttion in PHP ?

Started bypehache <pehache.7@gmail.com>
First post2017-05-07 10:19 +0200
Last post2017-05-18 08:14 -0400
Articles 10 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  page redirecttion in PHP ? pehache <pehache.7@gmail.com> - 2017-05-07 10:19 +0200
    Re: page redirecttion in PHP ? Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-07 07:43 -0400
    Re: page redirecttion in PHP ? Luuk <luuk@invalid.lan> - 2017-05-07 15:42 +0200
      Re: page redirecttion in PHP ? pehache <pehache.7@gmail.com> - 2017-05-07 16:12 +0200
        Re: page redirecttion in PHP ? pehache <pehache.7@gmail.com> - 2017-05-07 16:15 +0200
          Re: page redirecttion in PHP ? Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-07 13:49 -0400
            Re: page redirecttion in PHP ? pehache <pehache.7@gmail.com> - 2017-05-14 14:40 +0200
              Re: page redirecttion in PHP ? "J.O. Aho" <user@example.net> - 2017-05-14 16:31 +0200
                Re: page redirecttion in PHP ? pehache <pehache.7@gmail.com> - 2017-05-18 08:40 +0200
                  Re: page redirecttion in PHP ? Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-18 08:14 -0400

#17414 — page redirecttion in PHP ?

Frompehache <pehache.7@gmail.com>
Date2017-05-07 10:19 +0200
Subjectpage redirecttion in PHP ?
Message-ID<en83jtF9gfpU1@mid.individual.net>
Hi,

I have converted an old SPIP site into a static version, using wget. 
It's OK, except that URLs of the type

1) http://xxx/article.php3?id_article=6296

are now

2) http://xxx/article.php3?id_article=6296.html

Not a big deal, Google re-index the site from the root URL http://xxx/ 
which is still valid, but I wonder if there exist a simple mean to 
redirect the invalid URLs (1) to the valid ones (2) ?

I guess that it could be done by creating an appropriate "article.php3" 
file, but I am a full newbie in php...

Any help appreciated

[toc] | [next] | [standalone]


#17417

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-05-07 07:43 -0400
Message-ID<oen12l$ttk$2@jstuckle.eternal-september.org>
In reply to#17414
On 5/7/2017 4:19 AM, pehache wrote:
> Hi,
> 
> I have converted an old SPIP site into a static version, using wget.
> It's OK, except that URLs of the type
> 
> 1) http://xxx/article.php3?id_article=6296
> 
> are now
> 
> 2) http://xxx/article.php3?id_article=6296.html
> 
> Not a big deal, Google re-index the site from the root URL http://xxx/
> which is still valid, but I wonder if there exist a simple mean to
> redirect the invalid URLs (1) to the valid ones (2) ?
> 
> I guess that it could be done by creating an appropriate "article.php3"
> file, but I am a full newbie in php...
> 
> Any help appreciated
> 
> 

It would be better to handle this in Apache instead of PHP.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17418

FromLuuk <luuk@invalid.lan>
Date2017-05-07 15:42 +0200
Message-ID<590f2454$0$727$e4fe514c@news.xs4all.nl>
In reply to#17414
On 07-05-17 10:19, pehache wrote:
> Hi,
> 
> I have converted an old SPIP site into a static version, using wget. 
> It's OK, except that URLs of the type
> 
> 1) http://xxx/article.php3?id_article=6296
> 
> are now
> 
> 2) http://xxx/article.php3?id_article=6296.html
> 
> Not a big deal, Google re-index the site from the root URL http://xxx/ 
> which is still valid, but I wonder if there exist a simple mean to 
> redirect the invalid URLs (1) to the valid ones (2) ?
> 
> I guess that it could be done by creating an appropriate "article.php3" 
> file, but I am a full newbie in php...
> 
> Any help appreciated
> 
> 



   1 <?php
   2 $id_article=$_GET["id_article"];
   3 if (substr($id_article,-4)!="html") {
   4         header('Location: 
'.$_SERVER["SCRIPT_URI"]."?".$_SERVER["QUERY_STRING"].".html");
   5         exit(); }


[toc] | [prev] | [next] | [standalone]


#17421

Frompehache <pehache.7@gmail.com>
Date2017-05-07 16:12 +0200
Message-ID<en8oa0FdgglU1@mid.individual.net>
In reply to#17418
Le 07/05/2017 à 15:42, Luuk a écrit :
> On 07-05-17 10:19, pehache wrote:
>> Hi,
>>
>> I have converted an old SPIP site into a static version, using wget.
>> It's OK, except that URLs of the type
>>
>> 1) http://xxx/article.php3?id_article=6296
>>
>> are now
>>
>> 2) http://xxx/article.php3?id_article=6296.html
>>
>> Not a big deal, Google re-index the site from the root URL http://xxx/
>> which is still valid, but I wonder if there exist a simple mean to
>> redirect the invalid URLs (1) to the valid ones (2) ?
>>
>> I guess that it could be done by creating an appropriate
>> "article.php3" file, but I am a full newbie in php...
>>
>> Any help appreciated
>>
>>
>
>
>
>   1 <?php
>   2 $id_article=$_GET["id_article"];
>   3 if (substr($id_article,-4)!="html") {
>   4         header('Location:
> '.$_SERVER["SCRIPT_URI"]."?".$_SERVER["QUERY_STRING"].".html");
>   5         exit(); }

Great, this is exactly what I needed and it works just fine !

Thanks !

[toc] | [prev] | [next] | [standalone]


#17423

Frompehache <pehache.7@gmail.com>
Date2017-05-07 16:15 +0200
Message-ID<en8og9FdgglU2@mid.individual.net>
In reply to#17421
Le 07/05/2017 à 16:12, pehache a écrit :
> Le 07/05/2017 à 15:42, Luuk a écrit :
>> On 07-05-17 10:19, pehache wrote:
>>> Hi,
>>>
>>> I have converted an old SPIP site into a static version, using wget.
>>> It's OK, except that URLs of the type
>>>
>>> 1) http://xxx/article.php3?id_article=6296
>>>
>>> are now
>>>
>>> 2) http://xxx/article.php3?id_article=6296.html
>>>
>>> Not a big deal, Google re-index the site from the root URL http://xxx/
>>> which is still valid, but I wonder if there exist a simple mean to
>>> redirect the invalid URLs (1) to the valid ones (2) ?
>>>
>>> I guess that it could be done by creating an appropriate
>>> "article.php3" file, but I am a full newbie in php...
>>>
>>> Any help appreciated
>>>
>>>
>>
>>
>>
>>   1 <?php
>>   2 $id_article=$_GET["id_article"];
>>   3 if (substr($id_article,-4)!="html") {
>>   4         header('Location:
>> '.$_SERVER["SCRIPT_URI"]."?".$_SERVER["QUERY_STRING"].".html");
>>   5         exit(); }
>
> Great, this is exactly what I needed and it works just fine !
>
> Thanks !
>

Just had to replace the "?" by "%3F" in line 4, as the static URL in 2) 
is rather

2) http://xxx/article.php3%3Fid_article=6296.html

[toc] | [prev] | [next] | [standalone]


#17429

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-05-07 13:49 -0400
Message-ID<oenmh0$5v8$3@jstuckle.eternal-september.org>
In reply to#17423
On 5/7/2017 10:15 AM, pehache wrote:
> Le 07/05/2017 à 16:12, pehache a écrit :
>> Le 07/05/2017 à 15:42, Luuk a écrit :
>>> On 07-05-17 10:19, pehache wrote:
>>>> Hi,
>>>>
>>>> I have converted an old SPIP site into a static version, using wget.
>>>> It's OK, except that URLs of the type
>>>>
>>>> 1) http://xxx/article.php3?id_article=6296
>>>>
>>>> are now
>>>>
>>>> 2) http://xxx/article.php3?id_article=6296.html
>>>>
>>>> Not a big deal, Google re-index the site from the root URL http://xxx/
>>>> which is still valid, but I wonder if there exist a simple mean to
>>>> redirect the invalid URLs (1) to the valid ones (2) ?
>>>>
>>>> I guess that it could be done by creating an appropriate
>>>> "article.php3" file, but I am a full newbie in php...
>>>>
>>>> Any help appreciated
>>>>
>>>>
>>>
>>>
>>>
>>>   1 <?php
>>>   2 $id_article=$_GET["id_article"];
>>>   3 if (substr($id_article,-4)!="html") {
>>>   4         header('Location:
>>> '.$_SERVER["SCRIPT_URI"]."?".$_SERVER["QUERY_STRING"].".html");
>>>   5         exit(); }
>>
>> Great, this is exactly what I needed and it works just fine !
>>
>> Thanks !
>>
> 
> Just had to replace the "?" by "%3F" in line 4, as the static URL in 2)
> is rather
> 
> 2) http://xxx/article.php3%3Fid_article=6296.html
> 
> 

And if you do it with an Apache "permanently moved" order Google will
pick it up and change its database.  As it is, Google (and other search
engines) will continue indexing the old one for a very long time, since
you're giving an OK response to the old request.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#17439

Frompehache <pehache.7@gmail.com>
Date2017-05-14 14:40 +0200
Message-ID<enr1hpFg0v0U1@mid.individual.net>
In reply to#17429
Le 07/05/2017 à 19:49, Jerry Stuckle a écrit :
> On 5/7/2017 10:15 AM, pehache wrote:
>> Le 07/05/2017 à 16:12, pehache a écrit :
>>> Le 07/05/2017 à 15:42, Luuk a écrit :
>>>> On 07-05-17 10:19, pehache wrote:
>>>>> Hi,
>>>>>
>>>>> I have converted an old SPIP site into a static version, using wget.
>>>>> It's OK, except that URLs of the type
>>>>>
>>>>> 1) http://xxx/article.php3?id_article=6296
>>>>>
>>>>> are now
>>>>>
>>>>> 2) http://xxx/article.php3?id_article=6296.html
>>>>>
>>>>> Not a big deal, Google re-index the site from the root URL http://xxx/
>>>>> which is still valid, but I wonder if there exist a simple mean to
>>>>> redirect the invalid URLs (1) to the valid ones (2) ?
>>>>>
>>>>> I guess that it could be done by creating an appropriate
>>>>> "article.php3" file, but I am a full newbie in php...
>>>>>
>>>>> Any help appreciated
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>   1 <?php
>>>>   2 $id_article=$_GET["id_article"];
>>>>   3 if (substr($id_article,-4)!="html") {
>>>>   4         header('Location:
>>>> '.$_SERVER["SCRIPT_URI"]."?".$_SERVER["QUERY_STRING"].".html");
>>>>   5         exit(); }
>>>
>>> Great, this is exactly what I needed and it works just fine !
>>>
>>> Thanks !
>>>
>>
>> Just had to replace the "?" by "%3F" in line 4, as the static URL in 2)
>> is rather
>>
>> 2) http://xxx/article.php3%3Fid_article=6296.html
>>
>>
>
> And if you do it with an Apache "permanently moved" order Google will
> pick it up and change its database.  As it is, Google (and other search
> engines) will continue indexing the old one for a very long time, since
> you're giving an OK response to the old request.
>

Is it a problem if Google contine indexing the old URLs along with the 
new ones ?

[toc] | [prev] | [next] | [standalone]


#17440

From"J.O. Aho" <user@example.net>
Date2017-05-14 16:31 +0200
Message-ID<enr81cFhj3cU1@mid.individual.net>
In reply to#17439
On 05/14/17 14:40, pehache wrote:
> Le 07/05/2017 à 19:49, Jerry Stuckle a écrit :

>> And if you do it with an Apache "permanently moved" order Google will
>> pick it up and change its database.  As it is, Google (and other search
>> engines) will continue indexing the old one for a very long time, since
>> you're giving an OK response to the old request.
>>
> 
> Is it a problem if Google contine indexing the old URLs along with the
> new ones ?

For you will need to maintain the old ones, just think what happens next
time you do some changes, you will have to maintain 3 different ways to
access the content, then some years later 4 ways and so on.

If you tell it's permanent move, the search engine will remove the old
links and replace with the new ones and you don't need to maintain some
code to translate the old index way to the new one.

-- 

 //Aho

[toc] | [prev] | [next] | [standalone]


#17449

Frompehache <pehache.7@gmail.com>
Date2017-05-18 08:40 +0200
Message-ID<eo4tvgFpavlU1@mid.individual.net>
In reply to#17440
Le 14/05/2017 à 16:31, J.O. Aho a écrit :
> On 05/14/17 14:40, pehache wrote:
>> Le 07/05/2017 à 19:49, Jerry Stuckle a écrit :
>
>>> And if you do it with an Apache "permanently moved" order Google will
>>> pick it up and change its database.  As it is, Google (and other search
>>> engines) will continue indexing the old one for a very long time, since
>>> you're giving an OK response to the old request.
>>>
>>
>> Is it a problem if Google contine indexing the old URLs along with the
>> new ones ?
>
> For you will need to maintain the old ones, just think what happens next
> time you do some changes, you will have to maintain 3 different ways to
> access the content, then some years later 4 ways and so on.
>
> If you tell it's permanent move, the search engine will remove the old
> links and replace with the new ones and you don't need to maintain some
> code to translate the old index way to the new one.
>

OK. It will likely be the unique change, as I can't see any reason to 
make new changes in the future...

Anyway, how would "code" a permanent move in my case ? Reminder :

The old URLs :
    http://xxx/article.php3?id_article=xxxx
are now :
    http://xxx/article.php3%3Fid_article=xxxx.html

xxxx being any number

[toc] | [prev] | [next] | [standalone]


#17450

FromJerry Stuckle <jstucklex@attglobal.net>
Date2017-05-18 08:14 -0400
Message-ID<ofk304$pb8$1@jstuckle.eternal-september.org>
In reply to#17449
On 5/18/2017 2:40 AM, pehache wrote:
> Le 14/05/2017 à 16:31, J.O. Aho a écrit :
>> On 05/14/17 14:40, pehache wrote:
>>> Le 07/05/2017 à 19:49, Jerry Stuckle a écrit :
>>
>>>> And if you do it with an Apache "permanently moved" order Google will
>>>> pick it up and change its database.  As it is, Google (and other search
>>>> engines) will continue indexing the old one for a very long time, since
>>>> you're giving an OK response to the old request.
>>>>
>>>
>>> Is it a problem if Google contine indexing the old URLs along with the
>>> new ones ?
>>
>> For you will need to maintain the old ones, just think what happens next
>> time you do some changes, you will have to maintain 3 different ways to
>> access the content, then some years later 4 ways and so on.
>>
>> If you tell it's permanent move, the search engine will remove the old
>> links and replace with the new ones and you don't need to maintain some
>> code to translate the old index way to the new one.
>>
> 
> OK. It will likely be the unique change, as I can't see any reason to
> make new changes in the future...
> 

Every change is "likely to be the unique change..." :)

> Anyway, how would "code" a permanent move in my case ? Reminder :
> 
> The old URLs :
>    http://xxx/article.php3?id_article=xxxx
> are now :
>    http://xxx/article.php3%3Fid_article=xxxx.html
> 
> xxxx being any number

That is typically done in the configuration for your web server and you
need to ask in an appropriate newsgroup.


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web