繁体   English   中英

多个页面的htaccess重写规则

[英]htaccess rewrite rule for multiple pages

这似乎很简单,但是对我不起作用。 我试图将show.php?id = $ 1和producer.php?id = $ 1都重写为友好的URL。 第一个完美运行,第二个则不行。 如果我删除第一个,第二个可以正常工作。

我在这里做错了什么?

我的代码:

<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>

提前致谢!

您的问题很简单。

同一目录中不能有多个重写规则,每个IE都需要有一个单独的文件夹。 有一个名为“ show”的文件夹,并有htaccess文件,其中包含用于show的重写数据。

显示文件夹的.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)\.html$ /show.php?id=$1 [L]

</IfModule>

然后使用第二个重写规则创建另一个名为“生产者”的文件夹。

.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM