我需要将脚本根目录的索引重定向到其中的子目录。我想让它在以下所有条件下工作:
http://www.domain.com => http://www.domain.com/public
http://www.domain.com/dir => http://www.domain.com/dir/public
http://www.domain.com/dir1/dir2 => http://www.domain.com/dir1/dir2/public
答案 0 :(得分:0)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond !public/?$ [NC]
RewriteRule (.*) $1/public [L]