...

View Full Version : 301 Redirection from old article to the new



topdown.me
09-08-2011, 08:41 PM
Hello all.
My system based like that:
http://www.url.com/1(the id)/article_name
Whenever I change the article name, the url changes to:
http://www.url.com/1/article_new_name
In addition, I can access the article no matter what the name is, like that:
http://www.url.com/1/bfdgfdgdf
It will enter the same article as above.
My problem: I'm trying to do: 301 redirection to all pages that are NOT the original url(the real name of the article) and the article will be accessible only in one, original url - even after I change the article name it will redirect the old url to the new one (301 redircetion).
How I can do that?

Fou-Lu
09-08-2011, 09:02 PM
These have nothing to do with PHP. PHP does not (generally) handle the input types or directory levels for any type of control within PHP; it only cares about a querystring. Assuming that you don't have an actual directory structure that creates a new directory and index for each article, this will be an apache configuration issue for an htaccess file using mod_rewrite.

topdown.me
09-09-2011, 09:04 PM
These have nothing to do with PHP. PHP does not (generally) handle the input types or directory levels for any type of control within PHP; it only cares about a querystring. Assuming that you don't have an actual directory structure that creates a new directory and index for each article, this will be an apache configuration issue for an htaccess file using mod_rewrite.

Ok, so you just explained about my problem - how the hell i fix it?

tangoforce
09-09-2011, 09:41 PM
Post in the apache forum :thumbsup:

oracleguy
09-09-2011, 10:20 PM
Post in the apache forum :thumbsup:
Or just wait for the thread to get moved. :)


Fou-Lu is right you need to use an htaccess file and mod_rewrite to accomplish that. Have you ever used regular expressions before?

topdown.me
09-10-2011, 10:40 AM
Or just wait for the thread to get moved. :)


Fou-Lu is right you need to use an htaccess file and mod_rewrite to accomplish that. Have you ever used regular expressions before?

Yeah I used it to make a SEO-FRIENDLY url like that url i gave above, but how I make that users will be able to access the url only from the originial one, because if users write: http://www.url.com/1/bfdgfdgdf they will access article id 1, and if they write: http://www.url.com/1/RealArticleName it will access article id 1 too. I want to redirect all the url's that are not RealArticleName to the RealArticleName URL.
Got it?

Fou-Lu
09-10-2011, 06:38 PM
How are you going to determine what the 'real' article name is? The only requirement you have is a matching article id; there really isn't a way to determine what the title should be or whether its right or wrong.
You should choose either the id or the title, and issue a 404 when the correct isn't found. The description indicates that the article title can change, which means you should be using the id as the means to identify it, and not the title.

topdown.me
09-10-2011, 07:01 PM
How are you going to determine what the 'real' article name is? The only requirement you have is a matching article id; there really isn't a way to determine what the title should be or whether its right or wrong.
You should choose either the id or the title, and issue a 404 when the correct isn't found. The description indicates that the article title can change, which means you should be using the id as the means to identify it, and not the title.

Yeah I'm using the ID to identify it, but I want people to access the article only from the 'real' article name - How to determine it? from the database... everything is stored. I don't want to use the article name to identify it, I just want the article name to be the REAL one and if someone will write "ASDD" instead of the title it will redirect him to the REAL article name.

topdown.me
09-12-2011, 04:52 PM
2 days passed, any help?

Fou-Lu
09-15-2011, 09:01 PM
You don't.
If I supply it with a valid id and any other type of querystring variable that's not handled, it is ignored. There is no way for you to determine what title is valid versus invalid when you provide it with a valid identifier.
So ?someid=1&title=ignored is identical to ?someid=1&title=not+ignored when all you concern yourself with is the someid.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum