View Single Post
Old 01-05-2012, 01:32 PM   PM User | #12
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
Normally (which is a bit of a generalisation as there is no such thing tbh).....

You would have some clear and defined structure, and be working the other way round, that is:

Code:
LINK: mysite.com/tutorials/1 --->REDIRECT ---> mysite.com/show.php?id=1
LINK: mysite.com/tutorials/2 --->REDIRECT ---> mysite.com/show.php?id=2
LINK: mysite.com/tutorials/3 --->REDIRECT --->mysite.com/show.php?id=3
With this, your rewrite code can grab the '/1, /2, /3' and use that data in the redirect response - so you would have one rule to deal with all cases, plus a safety trap that redirects any non-existent files/pages should some user request something like mysite.com/tutorials/9999999999.

But you are working back to front because you are trying to transcribe:
Code:
LINK: blog-article.php?id=14 --->REDIRECT ---> /blog-post/logo-in-5-minutes-photoshop-tutorial/1/
From a code perspective there is no structure for mod_rewrite to work with, and you have no choice but to use an individual rule for id=14 for it to redirect to: /blog-post/logo-in-5-minutes-photoshop-tutorial/1/. If you only have 8 links it is not the end of the world, just write 8 rules. It's not optimal, but it should work without obvious issue.

MOD_REWRITE is not always the answer. Sometimes it is better to have a scripted handler that grabs the querystring, looks it up in a local array, table or database, and redirects based upon that. In your case, where your links are already making use of a querystring it may be a better option to put a simple php redirector together.

As for page ranking et al, it is not an area I can honestly say I am confident to give good advice in. I think in terms of logic, mostly, but this may be flawed and not match the metric used by search engines.

Quote:
id=6 etc once, you have queried the blog once it does not allow you to do the same for others.
Once you arrive at the target page (by redirection or directly) your links on that page should be fixed to point directly to the correct place and need no redirection, surely?

Last edited by leslie.jones; 01-05-2012 at 01:34 PM..
leslie.jones is offline   Reply With Quote