在codeigniter中重定向URL

I want to redirect a url in my lcalhost ,as when user types : mystring.localhost/CI to localhost/CI/Mycontroller/Myaction/mystring in codeigniter .its now showing Server not found and says browser Firefox can't find the server at www.mystring.localhost. How to do this ? Thanks in advance. I have this in my .htaccess :

    RewriteEngine On     
    RewriteCond %{HTTP_HOST} ^mystring\.localhost\CI\
    RewriteRule ^(.*)$ http://localhost/CI/Mycontroller/myaction/mystring/$1 [R=301]

On Windows edit the file C:\Windows\System32\drivers\etc\hosts and then append:

127.0.0.1 mystring.localhost

So it will redirect all requests from mystring.localhost to 127.0.0.1

On Linux is the same syntax but file is at /etc/hosts

And then, you must make some Alias or RewriteRule with RewriteCond on Apache configuration or .htaccess.

So if I understand correctly:

-Someone would type in mystring.localhost/CI, and you would like it to redirect them to a certain page with an action and value?

If so, you can set a page as the index page in \application\config\config.php

Its on line 30:

$config['index_page'] = 'Mycontroller/Myaction/mystring';

Otherwise in the controller that handles your index just do a redirect in it's __construct function.

There is most likely a solution involving the HTACCESS file but I am not very knowledgeable on that.

Hope this helps!

-Gui

add to c:\wamp\bin\apache\ApacheYOUVERSION\conf\extra\httpd-vhosts.conf

NameVirtualHost *.yourdomain.dev
<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/CI"
    ServerName *.yourdomain.dev
</VirtualHost>

Find #Include conf/extra/httpd-vhosts.conf in c:\wamp\bin\apache\ApacheYOUVERSION\conf\httpd.conf and delete # at the beginning

in your hosts file: 127.0.0.1 yourdomain.dev

add this to your htaccess:

RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).yourdomain.dev [NC]  
RewriteRule ([a-z0-9-]+)(/+.*) index.php/$1/%1$2 [QSA]