[英]mod_rewrite redirect root uri to index.php
我有一个.htaccess文件
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA]
如果我输入网址www.domain.com/something以及已加载的CSS和JS文件,则效果很好。
如果我仅输入www.domain.com(不带任何参数),则问题开始-浏览器显示为空白。 我需要添加什么,以便www.domain.com打开index.php,仍然将加载所有CSS文件?
我试过了
RewriteRule . /index.php [QSA,L]
但是它没有加载任何CSS文件,因为据我了解,它只是将所有内容都重定向到index.php(^ $而不是。也将所有内容都重定向到index.php)
我还尝试在index.php的开头添加内容,这样www.domain.com就会在php端重定向
header("Location: www.domain.com/begin");
但仍然无法正常工作,因为没有加载任何东西!
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.php [L,R=302]
应该加载CSS,javascript和图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.