0

My old website doesn't use a framework and the .htaccess worked fine, take a look at my .htaccess code below:

RewriteRule ^([a-zA-Z0-9_-]+)\.html solution.php?solution=$1 [L]

So the point there is that if it detects '.html' in the url, then the user is redirected to a PHP page passing any GET parameter.

Recently, I have converted my website to use the code igniter framework, so I have converted my .htaccess code to something below:

RewriteRule ^([a-zA-Z0-9_-]+)\.html index.php/solution/index/$1 [L]

I end up getting a page not found. However, if I still manually type

http://myhost/index.php/solution/index/xxx 

then it works, but if I type

http://myhost/xxx.html 

then it doesn't. My objective here is to maintain the original URL because it is indexed by Google and I do not want the previous visitors of my website to be getting a 'page not found' for my old links.

I need a fix or suggestion that might help. Looking forward to your response. Thanks.

it2051229
  • 339
  • 3
  • 13
  • 1
    Actually if you want to load a page which is been coded in codeigniter you have to follow the standard like www.myhost.com/class/method so you cannot simply do www.myhost.com/xxx.html. Sorry if you already familiar with this. And also .htaccess primary objective(In most cases) is to CLEAN the url i.e to hide index.php from the url. – Ramaraju.d Dec 22 '12 at 09:48
  • 1
    Actually Shomz answer is right, I removed the index.php through a .htaccess file and then I used the 'routes.php' of Code Igniter to do the redirection. Everything works fine now. – it2051229 Dec 23 '12 at 09:42

2 Answers2

1

Looks like you missed a lot of stuff while converting your website to use CI. Read about URL suffixes and also note you can use routes to redirect anything you can't handle normally using controllers.

You also need to modify your .htaccess to get rid of index.php since only modifying the config file won't work - there are a lot of resources about that, like this one.

Community
  • 1
  • 1
Shomz
  • 37,421
  • 4
  • 57
  • 85
0

Follow the codeigniter user guide: http://ellislab.com/codeigniter/user-guide/general/urls.html

Specially in following section:

  1. Removing the index.php file
  2. Adding a URL Suffix

If still having problem then check this wiki:

https://github.com/EllisLab/CodeIgniter/wiki/Removing-index.php-in-codeigniter-xampp-for-windows

or

How do I write a .htaccess file to make CodeIgniters URL routing work?

Community
  • 1
  • 1
itskawsar
  • 1,232
  • 1
  • 19
  • 30