Created
November 14, 2017 08:37
-
-
Save dendeffe/1a3903caf671b71617ca0675cab6d6f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = fopen("dicar.csv","r"); | |
while (($data = fgetcsv($file)) !== FALSE) { | |
//echo "<pre>";print_r($data); | |
$split_old_url = explode("?", $data[0]); | |
$querystring = $split_old_url[1]; | |
$url = $split_old_url[0]; | |
$url = explode('/', $url); | |
$final_url = ""; | |
$counter = 0; | |
foreach($url as $url_part) { | |
if($counter > 0) { | |
$final_url .= $url_part . "/"; | |
} | |
$counter++; | |
} | |
$final_url = substr($final_url, 0, -1); | |
if(strpos($querystring, "ID") !== false || strpos($querystring, "act") !== false || strpos($querystring, "Category") !== false || strpos($querystring, "nav=prof") !== false) { | |
echo "RewriteCond %{QUERY_STRING} " . $querystring . "<br>"; | |
echo "RewriteRule ^" . $final_url . "(.*)$ " . $data[1] . "? [R=301,L]<br>"; | |
} else { | |
echo "RewriteRule ^" . $final_url . "(.*)$ " . $data[1] . "? [R=301,L]<br>"; | |
} | |
} | |
fclose($file); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment