.htaccess rewrite / folder /子文件夹到/ folder /?子文件夹

时间:2015-04-15 22:26:30

标签: apache .htaccess

有没有办法在我的.htaccess中执行此操作?我尝试了一些解决方案,但无法使其正常工作......



Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/user/$1\ -f [NC]
RewriteRule ^(.+?)/?$ /folder/\?$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\ -f [NC]
RewriteRule ^(.+?)/?$ /\?$1 [L]




1 个答案:

答案 0 :(得分:0)

-f标记之前的空格不应转义。

将规则更改为:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/user/$1 -f [NC]
RewriteRule ^(.+?)/?$ /folder/?$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1 -f [NC]
RewriteRule ^(.+?)/?$ /?$1 [L]