自分のサーバー上のすべての.htaccessファイルを検索し、自分のページをSEOフレンドリーにするために必要な新しいコンテンツに置き換えるスクリプトを作成する必要があります。すべての.htaccessファイルを見つけてコンテンツをPHPスクリプトに置き換えてください
これまではすべての.htaccessファイルを見つけるためのスクリプトがいくつか出てきましたが、すべてのコンテンツを新しいものに置き換えて適切な権限で保存する必要があります。
私が必要とする余分な機能を追加するには、次のコードを手伝ってもらえますか?
<?php
function searchDir($dir) {
$dhandle = opendir($dir);
if ($dhandle) {
// loop through it
while (false !== ($fname = readdir($dhandle))) {
// if the element is a directory, and does not start with a '.' or '..'
// we call searchDir function recursively passing this element as a parameter
if (is_dir("{$dir}/{$fname}")) {
if (($fname != '.') && ($fname != '..')) {
echo "Searching Files in the Directory: {$dir}/{$fname} <br />";
searchDir("$dir/$fname");
}
// if the element is an .htaccess file then replace content
} else {
if($fname == ".htaccess")
{
echo "Replacing content of file ".$dir/$fname."<br />";
// I need the code for editing the files here.
}
}
}
closedir($dhandle);
}
}
searchDir(".");
?>
おかげで、とあなたの他のループを変更します。 – bikey77