Welcome Guest, Not a member yet? Register   Sign In
Custom URL?
#1

[eluser]semsemoo7[/eluser]
Hello,
I want to ask if i can use custom URLs in codeigniter like:
"http://www.site.com/article-section/article-title"

Where:
- "article-section" is a variable can be varied.
- "article-title" also is a variable.

Also may i can add more segments to the URL without being complied with function name or controller name?

I don't want to be forced to use the traditional method :
"http://www.site.com/categories/articles/article-title"

Where:
- "categories" is the name of the controller.
- "article" is the name of the function.
- "article-title" URL segment.

And please let me know if i can define some fixed definitions to the name of functions , e.g:
If i requested "article-section-1/article-title" it should execute the controller "categories" and the function "article" and the "article-title" is a variable.?
#2

[eluser]CroNiX[/eluser]
Sure, routes and remap() allow you to alter the default behavior.
#3

[eluser]semsemoo7[/eluser]
Thank you.
This solve part of the problem as this can make the "method" variable but i want to define some definitions for controllers e.g:
"/articles-sec-1/article-title" Where "articles-sec-1" refers to "categories" controller.

I tried to define it in "application/config/routes.php" like the example:
$route['product/(:any)'] = "catalog/product_lookup";
It worked but when using non English words it doesn't work.
#4

[eluser]CroNiX[/eluser]
Did you change the permitted_uri_chars setting in /application/config/config.php? The default is:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-=;';
That affects everything that is allowed in the URL, as a security measure.
#5

[eluser]semsemoo7[/eluser]
I enabled all chars for test and the problem is still.
#6

[eluser]semsemoo7[/eluser]
When i use English chars it works fine but when using any Unicode chars it doesn't work.
#7

[eluser]CroNiX[/eluser]
what is the route and controller you created?
#8

[eluser]semsemoo7[/eluser]
I created route with Arabic language:

$route['مقالات/:any'] = "example/index";

When i request it it displays 404 error "page not found".
But when i type it as:

$route['articles/:any'] = "example/index";

it works fine
#9

[eluser]CroNiX[/eluser]
(:any) should be in parenthesis.

Try:
Code:
$route[urlencode('مقالات') . '/(:any)'] = "example/index";
#10

[eluser]semsemoo7[/eluser]
The same problem "404 Page Not Found".




Theme © iAndrew 2016 - Forum software by © MyBB