Welcome Guest, Not a member yet? Register   Sign In
URLs... remove subfolder
#1

[eluser]umbungo[/eluser]
EDIT: issue now is getting routes to work with brackets in URL. see last post.

I have the following pages/addresses on my site..

example.com/main
example.com/main/first
example.com/main/second
(...)
example.com/another
example.com/yet_another
example.com/yet_another/more
example.com/even_more

Currently going to example.com shows example.com/main. This is great.

What I would really like to do is to show example.com/main/first by going to example.com/first, etc, whilst not breaking example.com/another etc.

How can i do this, please?

[edit:]FWIW if i am going to need to involve an array to include/exclude then it would be much easier to make an array of (another, yet_another, even_more, etc) than (first, second, etc.)
#2

[eluser]WanWizard[/eluser]
Use routes to route the URI example.com/first to main/first. See the User Guide.
#3

[eluser]umbungo[/eluser]
Code:
$mains =array('first', 'second', 'third',... 'fifteenth');

foreach($mains as $main){
    $sub = url_encode($main);
    $route[$sub.'/:any'] = "main/main/$sub/$1";
}
This does not work, is the only option to write out a rule for each of them??

** actually seems like it needs two rules for each...

$route['first/:any'] = "main/main/first/$1";
and $route['first'] = "main/main/first";

and they are case sensitive

let me know if there is a better way.

EDIT: also having problems where brackets are involved.. this gives a 404.




Theme © iAndrew 2016 - Forum software by © MyBB