I have a requirement where I need to redirect
domain.com/index.php, www.domain.com/index.php & www.domain.com/index/ to www.domain.com
My application is not using .htaccess file. It has to be done with php only.
I guess no solution without .htaccess file , so build one
Set main.php in your yii configuration, at component :
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
),
to be
LoadModule rewrite_module modules/mod_rewrite.so
then go to .htaccess file, and try to modify to be:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
if above does not work try with this:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
move .htaccess file to root directory, where is index.php resides.
www - protected - index.php - .htaccess
Restart your server and then all things will work
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.