2

I have to build up a bank search website. I want to rewrite url like below link

bank

Please see above link. In this when you select bank and all details the url is also changing.

I want to use same url in codeigniter website which is the replica of this site.

But all of you knows that codeigniter work on mvc so when this type of url comes to my system it says not found. So how can i achieve this with htaccess

here is my htaccess code

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
sanjay rathod
  • 77
  • 1
  • 2
  • 16
  • It can not be done with httpd rules only. You need to have (controller) code that follows uri segmentation. In other words you need to code the logic - what should happen when uri segments change. Likely you would need `controller/method/param1/param2/param3/param4` (all params should be optional to make next selection available). `.htaccess` is last think you should worry about and here is used just to rewrite `controller/method` part in URL. Unfortunatelly this is very complex question and you should put effort in work and show us some code. – Tpojka Jul 25 '16 at 22:35

2 Answers2

0

The .htaccess route with mod_rewrite

Add a file called .htaccess in your root folder, and add something like this:

RewriteEngine on
RewriteRule ^/?Some-text-goes-here/([0-9]+)$ /picture.php?id=$1

This will tell Apache to enable mod_rewrite for this folder, and if it gets asked a URL matching the regular expression it rewrites it internally to what you want, without the end user seeing it. Easy, but inflexible, so if you need more power:

for more info check this

Community
  • 1
  • 1
Vamsi Abbineni
  • 479
  • 3
  • 7
  • 23
  • Look my original website is this banksifsccode.co and i want to apply url on homepage so how did i achieve this – sanjay rathod Jul 25 '16 at 09:39
  • When you copy and paste an answer, please at least be loyal and mention the source! This answer was exactly copy and pasted from this [well written answer](http://stackoverflow.com/a/16389034/1908331) – EhsanT Dec 26 '16 at 00:46
-1

I created a site here, and URI segmentation is working fine using below code:

RewriteRule ^location/([^\.]+)/([^\.]+)/([^\.]+)/([^\.]+)$ index.php?bank=$1&se=$2&drt=$3&bnch=$4 [NC,L,QSA]
RewriteRule ^location/([^\.]+)/([^\.]+)/([^\.]+)$ index.php?bank=$1&se=$2&dtt=$3 [NC,L,QSA]
RewriteRule ^location/([^\.]+)/([^\.]+)$ index.php?bank=$1&ste=$2 [NC,L,QSA]
RewriteRule ^location/([^\.]+)$ index.php?bk=$1 [NC,L,QSA]
Quentin
  • 2,529
  • 2
  • 26
  • 32