[英].htaccess RewriteRule for category/subcategory/.../ in PHP
我在.htaccess
文件上有這個代碼
RewriteRule ^([0-9A-ZA-Z-]+)$ details.php?pro_id=$1 [QSA,NC,L]
當我訪問localhost/index.php
並打開任何顯示的產品示例localhost/product-1
,該產品將被顯示。 但是當我在localhost/country/city/place/product-1
添加產品時,我找不到頁面。 如何重寫.htaccess
代碼。 在details.php
頁面上編寫了用於顯示產品信息的代碼。
所以我有這個:
localhost/index.php - localhost/product-url
我需要這個:
localhost/index.php - localhost/country/city/place/product-1`.
注意:在某些情況下,我會在某些情況下有 2 個類別 3。
你的.htaccess
應該看起來像
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([a-zA-Z0-9|]+)/([^/]*)/(.*)$ details.php [B,QSA]
這將支持所有網址
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.