.htaccess重定向到目录

时间:2009-11-18 07:10:29

标签: .htaccess redirect directory

这是一个非常愚蠢的问题,但我在htaccess中相当弱。

我希望位于http://localhost/template/ *的所有文件(php,css,javascripts和图像)指向http://localhost/ *以及位于http://localhost/tempalte/404.php的404错误处理程序

我几乎得到了它,但是当我改变时

RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] to
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1.$2 [NC,L] 

我收到内部服务器错误。

# BEGIN website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] 
</IfModule>

Options -Indexes
# END website

1 个答案:

答案 0 :(得分:1)

编辑以反映评论,试试这个:

# BEGIN website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*\.(css|php|js|png|gif)) template/$1 [NC,L] 
</IfModule>

Options -Indexes
# END website