2017-12-05 8 views
0

나는이URL 재 작성 htaccess로 특정 단어

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

현재이이 URL에 대한 둘 다 작동이 :? 기사 ID = 100 및 기사 ID가 = 100/

를 관리하지만 싶습니다 가 특정 단어을 제외 : 기사 후 관리 ID = 100

이 URL이 금지됩니다 : 기사 ID가 = 100/

를 관리

니어 t articles? id = 100은 정상입니다

어떻게 변경할 수 있습니까?

나는

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

을 시도하지만 그것은 작동하지 않습니다. Thx

답변

0

여기에는 .htaccess 파일 이상이 포함됩니다. htaccess로

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; 

} 

?> 

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

에 htaccess로 한다 RewriteEngine 혼자 작업하기 위해 필요 PHP는 기능이 튜토리얼을 따라 http://www.simplecss3.com/tutorial/19/how-to-make-a-seo-friendly-url-using-php-and-htaccess