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