2017-12-05 2 views
0

Ich habe dieseURL Rewriting .htaccess bestimmtes Wort

RewriteRule ^article/?$ articles.php [L] 

Derzeit wird diese beiden für diese URL funktioniert:? Artikel-ID = 100 und Artikel-ID = 100/Verwalten

Aber ich möchte ausschließen ein bestimmtes Wort: nach Artikel verwalten id = 100

Diese uRL wird verboten: Artikel id = 100/

verwalten

Bu t Artikel? id = 100 ist OK

Wie kann ich das ändern?

Ich versuche

RewriteRule ^article/?$/^(Manage) articles.php [L] 
#or 
RewriteRule ^article/?$/(Manage) articles.php [L,R=404] 

, aber es funktioniert nicht. Thx

Antwort

0

Dies beinhaltet mehr als nur .htaccess-Datei. Ihr Bedarf eine PHP-Funktion mit der .htaccess allein zu arbeiten

function slug($string, $spaceRepl = "-") { 

    // Replace "&" char with "and" 

    $string = str_replace("&", "and", $string); 

    // Delete any chars but letters, numbers, spaces and _, - 

    $string = preg_replace("/[^a-zA-Z0-9 _-]/", "", $string); 

    // Optional: Make the string lowercase 

    $string = strtolower($string); 

    // Optional: Delete double spaces 

    $string = preg_replace("/[ ]+/", " ", $string); 

    // Replace spaces with replacement 

    $string = str_replace(" ", $spaceRepl, $string); 

    return $string; 

} 

?> 

und Ihre .htaccess RewriteEngine On

RewriteRule ^articles/([0-9]+)/([a-zA-Z0-9_-]+) articles.php?id=$1 

Folgen dieses Tutorial http://www.simplecss3.com/tutorial/19/how-to-make-a-seo-friendly-url-using-php-and-htaccess

Verwandte Themen