Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

page redirecttion in PHP ?

12 views
Skip to first unread message

pehache

unread,
May 7, 2017, 4:19:16 AM5/7/17
to
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


Jerry Stuckle

unread,
May 7, 2017, 7:43:25 AM5/7/17
to
It would be better to handle this in Apache instead of PHP.

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

Luuk

unread,
May 7, 2017, 9:42:49 AM5/7/17
to
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(); }



pehache

unread,
May 7, 2017, 10:12:20 AM5/7/17
to
Great, this is exactly what I needed and it works just fine !

Thanks !

pehache

unread,
May 7, 2017, 10:15:41 AM5/7/17
to
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


Jerry Stuckle

unread,
May 7, 2017, 1:49:28 PM5/7/17
to
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.

pehache

unread,
May 14, 2017, 8:40:32 AM5/14/17
to
Is it a problem if Google contine indexing the old URLs along with the
new ones ?


J.O. Aho

unread,
May 14, 2017, 10:31:13 AM5/14/17
to
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

pehache

unread,
May 18, 2017, 2:40:54 AM5/18/17
to
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

Jerry Stuckle

unread,
May 18, 2017, 8:14:11 AM5/18/17
to
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.
0 new messages