Reputation: 11
I am trying to redirect these URLs:
http://www.example.com/welcome/index
http://www.example.com/welcome
http://www.example.com/index.php
To this URL:
Using a rewrite rule.
I have tried this (which isn't working):
Redirect 301 http://www.example.com/welcome/index$ http://www.example.com/
Upvotes: 0
Views: 1223
Reputation: 664
Please add your below code in your route .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Additionally, check your $config['base_url']
and add your base url:
$config['base_url'] = http://localhost/project/
Then it will work like as charm and you will redirect to another controller without the index.php
Example: http://localhost/project/home
Use of index function:
www.example.com/welcome/index
If you need to use index function in URL, For that Please set route in routes file.
Please check it with as above
Upvotes: 0