[英]htaccess rewrite rule for multiple pages
this seems so simple, but it's not working for me. 这似乎很简单,但是对我不起作用。 I am trying to have both show.php?id=$1 and producer.php?id=$1 rewrite as friendly URLs.
我试图将show.php?id = $ 1和producer.php?id = $ 1都重写为友好的URL。 The first one works perfectly, the second does not.
第一个完美运行,第二个则不行。 If I remove the first, the second works fine.
如果我删除第一个,第二个可以正常工作。
What am I doing wrong here? 我在这里做错了什么?
My code: 我的代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\.html$ /show.php?id=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\.html$ /producer.php?id=$1 [L]
</IfModule>
Thanks in advance! 提前致谢!
Your problem is quite simple. 您的问题很简单。
You cannot have more than one rewrite rule for the same directory, you would need to have a separate folder for each IE. 同一目录中不能有多个重写规则,每个IE都需要有一个单独的文件夹。 have a folder called "show" and have the htaccess file that contains the rewrite data for show.
有一个名为“ show”的文件夹,并有htaccess文件,其中包含用于show的重写数据。
.htaccess for show folder: 显示文件夹的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\.html$ /show.php?id=$1 [L]
</IfModule>
Then have another folder called "producer" with the 2nd rewrite rule. 然后使用第二个重写规则创建另一个名为“生产者”的文件夹。
.htaccess for producer folder: .htaccess用于生产者文件夹:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\.html$ /producer.php?id=$1 [L]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.