[英]Url rewriting htaccess specific word
I have this 我有这个
RewriteRule ^article/?$ articles.php [L]
Currently this works both of them for these url : articles?id=100 and articles?id=100/Manage 目前,这两个选项都适用于以下网址:article?id = 100和article?id = 100 / Manage
But I would like to exclude a specific word : Manage after articles?id=100 但是我想排除一个特定的词 :文章后管理?id = 100
This url will be forbidden : articles?id=100/manage 该网址将被禁止:article?id = 100 / manage
But articles?id=100 is OK 但是article?id = 100还可以
How can I change this ? 我该如何更改?
I try 我尝试
RewriteRule ^article/?$/^(Manage) articles.php [L]
#or
RewriteRule ^article/?$/(Manage) articles.php [L,R=404]
But It doesn't work. 但这行不通。 Thx
谢谢
This involves more than just .htaccess file. 这不仅涉及.htaccess文件。 Your need a php function to work alone with the .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;
}
?>
and your htaccess RewriteEngine On 和你的htaccess RewriteEngine上
RewriteRule ^articles/([0-9]+)/([a-zA-Z0-9_-]+) articles.php?id=$1
Follow this tutorial http://www.simplecss3.com/tutorial/19/how-to-make-a-seo-friendly-url-using-php-and-htaccess 遵循本教程http://www.simplecss3.com/tutorial/19/how-to-make-a-seo-friendly-url-using-php-and-htaccess
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.