重定向到子文件夹中的索引

时间:2014-11-27 07:22:20

标签: php .htaccess mod-rewrite

我在root/en内有一个.htaccess文件,当您输入网址root/en时,我希望网站重定向到root/en/public/index.php并在那里找到索引。我有这个解决方案但由于某种原因它不起作用:

RewriteEngine on
RewriteBase /en

ReWriteCond %{REQUEST_URI} !en/public/
ReWriteRule ^(.*)$ en/public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php?/$0 [PT,L] 

1 个答案:

答案 0 :(得分:0)

如果您将其用作前置控制器,请使用:

RewriteEngine on
RewriteBase /en/

RewriteRule ^$ public/index.php [L]

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