/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php //Set Options $old_url_text_file = "old_urls.txt"; $base_url = "http://www.premierfoot.com/"; $replacement_base_url = "http://www.premierfoot.com/"; //Make Sure to Add Trailing Back Slash $new_url_text_file = "new_urls.txt"; $redirect_text_file = "new_urls.txt"; $default_redirection_page = "index.html"; //Create Array of Old Urls from Text File Contents //Create Array of New Urls from Text File Contents // $new_url_list = file_get_contents($new_url_text_file); // $new_urls = explode("\n", $new_url_list); // $new_urls = array_filter(array_map('trim', $new_urls)); //Print RewriteBase Outside of Loop print "RewriteBase /" . "<br />"; //Loop Through Urls and Generate 301 Redirect Syntax foreach ($old_urls as $old_url) { if($old_url !== "/") { print "RewriteRule ^" . $old_url . "$" . " " . $replacement_base_url . $default_redirection_page . " " . "[R=301,L]" . "<br />"; } } ?>