Welcome Guest, Not a member yet? Register   Sign In
url rewriting vs routing
#1

[eluser]mr_prasanna[/eluser]
Hi,

We've created a simple ecommerce site using reactor 2.0.2
We now need to get the friendly urls in place and stuck with this.

There are two apps 1. store and 2. admin we've added rules to hide index.php under admin and it works fine. With store we want to map urls like below and it's not working. please help.
Thanks in advance.

Code:
mysite.com/store/cart/show TO mysite.com/store/index.php/cart/show

Code:
mysite.com/store/some-category/some-product TO mysite.com/store/index.php/product/info/$1/$2

Where, $1 is some-category and $2 is some-product


Code:
mysite.com/store/some-category TO mysite.com/store/index.php/category/list/$1

mysite.com/store/some-category/some-product
#2

[eluser]Italo Domingues[/eluser]
The correct way is you make the settings in the file routes.php friendly url that is in application/config. For each product you must create a mapping in the user guide you can see how (http://ellislab.com/codeigniter/user-gui...uting.html).

Have to hide the index.php, create file .htaccess file in the directory where the index.php with the following content:

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#3

[eluser]mr_prasanna[/eluser]
What if there is something like below? Or rather I would like to ignore if the URLs are like store/cart, store/account, store/auth etc. and route if it's not any of these.

$route['store/cart']
$route['store/(:any)']
#4

[eluser]Italo Domingues[/eluser]
In the example below, when calling a url store/12/150, the CI will automatically route to the store controller by calling the info passing two parameters, $1 and $2, where $1 may be the $2 category and the product code.

Code:
$route['store/(:num)/(:num)'] = "store/info/$1/$2"
#5

[eluser]mr_prasanna[/eluser]
Ok, I had some luck with

$route['(:any)/(:any)'] = "product/info/$1/$2";

But, for some reason the page title was 404 page not found. Content was fine.

Also, for first (:any) I think I need a regex that gets me any string except (cart|product|account|auth). Please help if you can.




Theme © iAndrew 2016 - Forum software by © MyBB