[英].htaccess 2 urls on index.php
I search alot on google but not get any help. 我在Google上搜索了很多,但没有得到任何帮助。
I have 2 urls like this 我有2个网址
and i need them like this 我需要他们这样
Here my .htaccess
file 这是我的
.htaccess
文件
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?page_id=$1&title=$2 [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?post_id=$1&title=$2 [L]
Above code always open page_id
. 上面的代码始终打开
page_id
。 Is it possible to make it work or may I make another file for details page? 是否可以使其正常工作,或者我可以为详细信息页面制作另一个文件?
The two rewrite patterns are identical ( ^([^/]*)/([^/]*)\\.html$
), and Apache has no way of telling the difference between the two. 两种重写模式是相同的(
^([^/]*)/([^/]*)\\.html$
),Apache无法分辨两者之间的区别。
Consider changing your URI structure to the following: 考虑将您的URI结构更改为以下内容:
/id/name.html
, example: /203/page-name.html
/id/name.html
,例如: /203/page-name.html
/posts/id/name.html
, example /posts/12/post-name.html
/posts/id/name.html
,例如/posts/12/post-name.html
As an alternative, you can use one rule to rewrite to, say, index.php?id=$1&title=$2
, eliminating the need for two different query parameters. 或者,您可以使用一条规则来重写为
index.php?id=$1&title=$2
,从而不需要两个不同的查询参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.