[英]Mod_Rewrite file to subfolder in .htaccess
I'm trying to redirect a folder to a file. 我正在尝试将文件夹重定向到文件。 I want to redirect:
我想重定向:
www.mysite.com/category/customername
www.mysite.com/category/customername
AND 和
www.mysite.com/category/customername/
www.mysite.com/category/customername/
TO 至
www.mysite.com/category.php?customer=customername
www.mysite.com/category.php?customer=customername
This is working, but "customer" become "customername.php" and not "customer" 这是可行的,但是“客户”变成“ customername.php”而不是“客户”
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/(.*)$ category.php?customer=$1 [L]
How could i remove ".php" via .htaccess? 如何通过.htaccess删除“ .php”? Thank you!
谢谢!
You can use: 您可以使用:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^category/([\s\w-]+)/?$ category.php?customer=$1 [L,NC,QSA]
Thank you anubhava, i have do a dynamic rule: 谢谢你,我已经做了一个动态的规则:
RewriteRule ^(.+[^/])/(\w+)/?$ $1.php?customer=$2 [L]
Tested for 经过测试
www.mysite.com/category_1/customer AND 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 AND www.mysite.com/category_X/customer/
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/
Bye 再见
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.