Welcome Guest, Not a member yet? Register   Sign In
url rewrite problem


I am facing this problem.

I have a controller called welcome.php which is called as the index page.
Thanks to the url rewrite I have a clean url like this:
instead of

Now when I add another function (Like test) in welcome.php the url is

Is there a way to remove the welcome to?

My current htaccess file is:
RewriteEngine on
RewriteBase /cvp/
RewriteCond $1 !^(index\.php|img|js|css|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /cvp/index.php/$1 [L]

Thanks for any input.

[eluser]Derek Allard[/eluser]
You bet. Set your config['index_page'] to '' (empty quotes) and use CI's anchor() function.

It is blank. It needs to be blank for the rewrite.

[eluser]Derek Allard[/eluser]
and the anchor funtion is automatically adding in "welcome"? Could you share your code?

If you have a fresh installation of codeigniter
where the default controller in routes.php is still set
to "welcome" and you load the page, the first URI segment
is not displayed (I don't know how CI hides it).
As soon you click at a link, the controller name
is displayed as URI segment 1 and the function name
is added as URI segment 2 (if you call any other function then index).
In your case
If you just want to have "test" in your url

you will have to add a controller named "test" (controller/test.php
with the class name "Test"

Did you mean that?

I think you're looking for "routes" functionality.

In your config/routes.php file:
$route['test/:any'] = "welcome/test/";
$route['test'] = "welcome/test/";

Something like that should do it.

Shall test this but then I loose the ability to add it on the fly. Then I should edit 2 files. The main controller class and then the routes file.

You can also remap the controller, which gives a different result, but you might be able to think your way into a solution which works for you.

First function after the _constructor():
if ($method == 'index')
But I think you would have to roll your "welcome" function into your test funtion to make this work for you.

Theme © iAndrew 2016 - Forum software by © MyBB