R
R
Rocker_dead2014-10-22 23:49:02
URL Handling
Rocker_dead, 2014-10-22 23:49:02

How to make CNC in PHP from database fields?

Couldn't find a good answer anywhere. Himself in php is not very good, only basic knowledge.
Now the site is configured with a manual redirect of the type

if($_SERVER['REQUEST_URI'] == "/fabrik.php?fdoc=18")
{
header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://".$_SERVER['HTTP_HOST']."/bordignon-camillo");
exit;
}

And so for each page. And I want everything to be automatic. In the database, I created a column corresponding to each ID of my CNC (the "seo" column for example), and it is necessary that the redirect be from the address "/fabrik.php?fdoc=$id" to "/$seo" roughly speaking.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zwebz, 2014-10-23
@zwebz

Alternatively, you can take the fdoc parameter from the $_GET variable, and fetch the SEO value from the database by the ID column. Then substitute this value in header()

$sql = "SELECT seo FROM tbl WHERE ID = $_GET['fdoc'] ";
Header("Location: http://".$_SERVER['HTTP_HOST']."/".$seo);

R
Rocker_dead, 2014-10-23
@Rocker_dead

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fabrik.php?fdoc=176$ /bianchini-capponi [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bianchini-capponi$ /fabrik.php?fdoc=176 [L]
##################
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME } !-d
RewriteRule ^fabrik.php?fdoc=17$ /bonaldo [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bonaldo$ /fabrik.php?fdoc= 17[L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question