Welcome Guest, Not a member yet? Register   Sign In
how can i get url look like that?
#1

[eluser]7amza[/eluser]
Hello ,
i want ask you if you know any method to get url look like this one :
http://domain.com/Articles?Category=45
and :
http://domain.com/Controler:Articles/Category:45/
the controller name is Articles ; and Category is a method in the controller and 45 is variable .
thanks , and sorry for my bad english .
#2

[eluser]SpooF[/eluser]
Make a route.

Code:
$route['(:any)?(:any)=(:num)'] = '$1/$2/$3';
$route['Controller:(:any)/(:any):(:num)'] = '$1/$2/$3';
#3

[eluser]7amza[/eluser]
Hello Spoof
i made route like that :
Code:
$route['Category:(:num)/(:any)'] = 'Category/Select/$1/$2';
and it show me the 403 error :
Forbidden

You don't have permission to access /news/Category:5/TeleCommunication/ on this server.
----
news = codeigniter folder .(root)
category = controller .
5 = variable(id) .
Telecommunication = variable(title of category)
notice : i use htaccess to remove index.php from the url .
#4

[eluser]7amza[/eluser]
any idea brothers?
#5

[eluser]loosetops[/eluser]
So far you have only provided what you want the URLS to look like.

What is the current access URL and how do you want them to look like? With that we can see what exactly you are doing wrong.
#6

[eluser]7amza[/eluser]
thanks for for your reply , but i give all requested information in the first posr ;
current access URL : http://site.com/Articles/Category/Press/45/
and the result i look for : http://site.com/Service:Articles/Category:Press/ID:45/
notice : i use htaccess to remove index.php from the url .
#7

[eluser]loosetops[/eluser]
Code:
$route['Service:(:any)/(:any):(:any)/ID:(:num)'] = '$1/$2/$3/$4';

You will have to do that for all the controllers whose URLs you want to change.
#8

[eluser]7amza[/eluser]
i did it but it show me the 403 Eror !
#9

[eluser]loosetops[/eluser]
I have created a controller to try and imitate your urls.

Here is the controller
Code:
<?php

class Articles extends Controller {

    function __construct(){
        parent::Controller();

    }
    
    function category($cat=NULL,$id=NULL){
        echo 'cat: ',$cat,', id: ',$id;
    }
}

The URLs for this controller are

Code:
http://site.com/articles/category/press/45

The page output for the above URL is
Quote:cat: press, id: 45

I applied this route
Code:
$route['service:(:any)/(:any):(:any)/ID:(:num)'] = '$1/$2/$3/$4';
I got the desired output.

Another less specific route that worked is
Code:
$route['service:(:any)/(:any):(:any)/:any:(:num)'] = '$1/$2/$3/$4';

Make sure the first letter capitalization for "service" is correct. Other than that I don't see why the routes aren't working for you. If you can access the controller method using the original URL, a correct route should not take you to a 403 page.
#10

[eluser]7amza[/eluser]
loosetops thank you very much it works the problem was with the letter capitalization .




Theme © iAndrew 2016 - Forum software by © MyBB