我有这个
RewriteRule ^article/?$ articles.php [L]
当前这两个都适用于这些URL:文章?id = 100和文章?id = 100/manage
但是我想排除特定的单词:管理文章?id = 100
将禁止此URL:文章?id = 100/manage
但是文章?id = 100可以
我该如何更改?
我尝试
RewriteRule ^article/?$/^(Manage) articles.php [L]
#or
RewriteRule ^article/?$/(Manage) articles.php [L,R=404]
但行不通。thx
这不仅涉及.htaccess文件。您需要PHP功能与.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;
}
?>
和您的htaccess重新撰写
RewriteRule ^articles/([0-9]+)/([a-zA-Z0-9_-]+) articles.php?id=$1
遵循本教程http://www.simplecsss3.com/tutorial/19/how-to-make-a-seo-seo-frelcy-rightly-url-using-php-and-htaccess