简体   繁体   中英

mod_rewrite redirect root uri to index.php

I have a .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?q=$1 [QSA]

It works fine if i enter url www.domain.com/something and also css and js files ar loaded.
The problem begins if i enter just www.domain.com (without any params) - browser displays blank. What i need to add so that www.domain.com opens index.php and still all the css files will load?

I tried this

RewriteRule . /index.php [QSA,L] 

but it then none of css files are loaded because I understand that it simply redirects everything to index.php (^$ instead of . also redirects everything to index.php)

I also tried adding at the beginning of index.php so www.domain.com would redirect at the php side

header("Location: www.domain.com/begin");

but still it is not working because nothing is loaded!

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.php [L,R=302]

Should load the CSS, javascript and images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM