簡體   English   中英

Mod_Rewrite文件到.htaccess中的子文件夾

[英]Mod_Rewrite file to subfolder in .htaccess

我正在嘗試將文件夾重定向到文件。 我想重定向:

www.mysite.com/category/customername

www.mysite.com/category/customername/

www.mysite.com/category.php?customer=customername

這是可行的,但是“客戶”變成“ customername.php”而不是“客戶”

Options +FollowSymLinks
RewriteEngine On    
RewriteRule ^category/(.*)$ category.php?customer=$1 [L]

如何通過.htaccess刪除“ .php”? 謝謝!

您可以使用:

Options +FollowSymLinks -MultiViews

RewriteEngine On    
RewriteRule ^category/([\s\w-]+)/?$ category.php?customer=$1 [L,NC,QSA]

謝謝你,我已經做了一個動態的規則:

RewriteRule ^(.+[^/])/(\w+)/?$ $1.php?customer=$2 [L]

經過測試

www.mysite.com/category_1/customer和www.mysite.com/category_1/customer/ www.mysite.com/category_2/customer AND www.mysite.com/category_2/customer/ www.mysite.com/category_X/customer和www.mysite.com/category_X/customer/

再見

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM