我有这个
RewriteRule ^article/?$ articles.php [L]
目前这适用于这些网址:文章?id = 100和文章?id = 100 /管理
但我想排除特定字词:管理文章后?id = 100
此网址将被禁止:文章?id = 100 / manage
但文章?id = 100就可以了
我该如何更改?
我试试
RewriteRule ^article/?$/^(Manage) articles.php [L]
#or
RewriteRule ^article/?$/(Manage) articles.php [L,R=404]
但它没有用。 THX
答案 0 :(得分:0)
这不仅仅涉及.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 RewriteEngine On
RewriteRule ^articles/([0-9]+)/([a-zA-Z0-9_-]+) articles.php?id=$1
按照本教程http://www.simplecss3.com/tutorial/19/how-to-make-a-seo-friendly-url-using-php-and-htaccess