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?

Community
  • 1
  • 1
Rosamunda
  • 14,620
  • 10
  • 40
  • 70

1 Answers1

0

Yes it affects SEO, the severity depends on what you're doing on the page based on the variable.

If /content.php?id=1 has different content than /content.php Google will not know about /content.php?id=1 because it's not being set in a sitemap. This will greatly affect SEO.

If /content.php?id=1 only changes a couple of variables on the page for example /content.php displays "DEAR SIR" and /content.php?id=1 "Dear BILLY" it won't penalize you too much.

Billy
  • 126
  • 1
  • 10
  • My problem being that I do a redirect of the url from /content.php?id=1 to /titulo-1 and I don't rewrite the url, so the url addressbar still shows /content.php?id=1 when people clicks /titulo-1 – Rosamunda Aug 06 '19 at 13:03
  • Yes that'll effect SEO. You won't have an informative url address and without links on the page for google to crawl, it won't know that the pages exist. Even with a sitemap you'll get penalized by not having them accessible. – Billy Aug 07 '19 at 08:39