0

Explanation of the problem

I want to redirect each page from a non-friendly url to a friendlier one.

I've already achieved that using mod_rewrite in an .htaccess file that does send every visitor to redirect.php. Then that file does handle where to redirect every visitor, according to a parameter taken from the url.

The redirection does work in the sense of getting people from /content.php?id?1 to /titulo-contenido-1 I want to know why the url does not look "pretty" after the redirection.

For example, when you click a link in a Drupal forum (I'm not using Drupal, this is just as an example), the URL looks friendly: enter image description here

Whith my script, even if the user clicks on a friendly url, the browser, after the page is rendered, shows the unfriendly one.

How do I get the friendly url:

I have a PHP page that has a short form in it: The form contains an input for title, an input for a url and textarea.

When I save the form's contents, it gets saved into a MySQL database as:

id- X

title- This is my title

textarea- "....."

url- this-is-my-title

When a visitor clicks on mywebsite.com/this-is-my-title, it is redirected (through the .htaccess rule) to redirect.php

There, it catches the "this-is-my-title" part and saves it into a variable.

Then it consults the database to get the id from the url, and finally it sets a redirection:

$reenvioA = $http.'://'.$sitio.'/contenido.php?id='.$id;  
header('Location: '.$reenvioA);

So the links in the website are all friendly, and the user gets redirected like that.

It does work, but the user always sees the real link.

I have several types of links with different structures that need redirection (it all gets done in that redirection.php file with different rules), because I'm importing stuff from different old websites into a big new one, and I need people to be redirected properly if they click in a link with an old format.

My big, fat question

Can that affect SEO? or it's just a horrible solution that does work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.