0
votes

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:

http://www.example.com/

Using a rewrite rule.

I have tried this (which isn't working):

Redirect 301 http://www.example.com/welcome/index$ http://www.example.com/
1
@Alex my default controller is welcome and it is already redirect all the links to my base url but i want to change the url also mean to say that when i open this example.com/welcome/index then the url changes to example.com thanks a lot - deep
is this the only controller on your site? - Alex
What is your $config['base_url'] in config file? - Kamlesh
@Alex no this is not the only controller but acc. to seo all the links must refer to base url which is example.com - deep

1 Answers

0
votes

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