我只想得到一个快速的htaccess的重定向。即:
I just want to get a quick htaccess redirection. ie:
domain.com/subfolderGreen - > domain.com/index.php?folder=subfolderGreen
domain.com/subfolderGreen --> domain.com/index.php?folder=subfolderGreen
(注意,subfolderGreen实际存在)
(note that the subfolderGreen actually exists)
我一直很努力,但未能得到所需的正则表达式。
I've been trying but couldn't get to the regex needed.
感谢。 一。
增加:
对不起,我想这适用于任何子文件夹,而不仅仅是subfolderGreen 我使用的是
Sorry, i want this to work for any subfolder, not just "subfolderGreen" I'm using
重写规则^ /([^ /] +)/ $ /index.php?folder=$1 [L]
RewriteRule ^/([^/]+)/?$ /index.php?folder=$1 [L]
,但它不工作。 任何线索?
but it's not working. any clues?
我会认为你的例子会造成死循环,因为赛事的index.php你在做什么。试试这个:
I would think your example would cause an endless loop since /index.php matches what you are doing. Try this:
RewriteRule ^([A-Za-z0-9]+)/?$ /index.php?folder=$1 [L]
如果你想让它工作存在的所有目录,这将可能正常工作。
If you want it to work for all directories that exist, this will probably work as well.
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)/?$ /index.php?folder=$1 [L]