从文本文件创建301重定向模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从文本文件创建301重定向模板相关的知识,希望对你有一定的参考价值。
<?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"; //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(" ", $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 />"; } } ?>
以上是关于从文本文件创建301重定向模板的主要内容,如果未能解决你的问题,请参考以下文章