Php .htaccess包含3个以上参数的干净url
我是.htaccess的新手,在让它为我清理url时似乎遇到了一些问题 我有Php .htaccess包含3个以上参数的干净url,php,.htaccess,mod-rewrite,url-rewriting,Php,.htaccess,Mod Rewrite,Url Rewriting,我是.htaccess的新手,在让它为我清理url时似乎遇到了一些问题 我有 site.com?p=article&id=3&read=article title 我可以让第一个变量正常工作,比如site.com/articles。但是,当我试图更进一步时,服务器说它找不到它。我试过几种方法,但似乎都不管用 RewriteRule ^([a-zA-Z0-9]+)$ index.php?p=$1 RewriteRule ^([a-zA-Z0-9]+)/$ index.php?p=
site.com?p=article&id=3&read=article title
我可以让第一个变量正常工作,比如site.com/articles。但是,当我试图更进一步时,服务器说它找不到它。我试过几种方法,但似乎都不管用
RewriteRule ^([a-zA-Z0-9]+)$ index.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?p=$1
上面的这个正在工作
我试过了
RewriteRule ^([a-zA-Z0-9-z\-]+)(/([a-zA-Z0-9-z\-]+))?/?$ index.php?p=$1&i=$2
及
最后两个不起作用。请帮忙。谢谢让我们试试这样的东西好吗
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?p=$1&id=$2&read=$3 [L]
%{QUERY_STRING}是您要查找的内容 这是我在类似情况下使用的:
RewriteRule ^/(.*) /index.php?r=/$1&%{QUERY_STRING} [L]
嗨,谢谢你的帮助。你知道这篇文章的标题有没有空格会影响它的阅读方式吗?i、 e.&read=诸如此类。。。谢谢,谢谢你的帮助。你知道这篇文章的标题有没有空格会影响它的阅读方式吗?i、 e.&read=诸如此类。。。ThanksSpaces将被编码,并在浏览器中显示为%20如果你是这样问的,最好不要在URL中使用空格,如果可能的话,我可能会用连字符替换它们。现在在我的web浏览器中查看URL,stackoverflow也会用连字符替换空格。啊,好吧,那么在php中使用类似str_replace的东西?我假设字符串中的r代表脚本中的p,对吗?
RewriteRule ^/(.*) /index.php?r=/$1&%{QUERY_STRING} [L]