Welcome Guest, Not a member yet? Register   Sign In
friendly URL's and .htaccess

Hi everyone...

This is my first time using CodeIgniter and it's really awesome. I am struggling a bit with how to implement search engine friendly URL's.

I made a .htaccess file for my website and filled it with some code I found on a site. Next I changed the $config['uri_protocol'] = "REQUEST_URI"; and removed the index.php from $config['index_page'] = "";

All of this works on my localhost (I use XAMPP on my dev machine), but not on my host's server.

If I have a few links that point to another page(view), it is my understanding that I should call the controller that loads that view, right? In other words my href should call a controller, to my understanding. For example, I have my main page (welcome page) and it has my template on it (which I loaded with three separate views, header, body and footer). Now in my body I have links to my other pages, blog, forum, links, photos...etc.. What would my href look like to call those pages? I currently use on my localhost(this only works on my localhost currently) <a href='MyLinks'>Links</a> then my URL changes to http://mysite.localhost/MyLinks and then calls the MyLinks controller which brings up my view. My question is, is this the right way to use the href?? also, why does this not work on my host's server, is there something I can change? Could there be a problem wiht my .htacccess?

[eluser]Jamie Rumbelow[/eluser]
A lot of the time you don't need to set the URI_PROTOCOL to REQUEST_URI. Switch it around the other settings, and see if that works.

I have tried all the settings, there are 5 different settings, I have tried all 5. None work on my hosting server.

Oh wow, I have spent about roughly 8 hours trying to figure out how to call pages using hrefs and managaging to use friendly URL's.

What I did to get it working :

system\application\config\config.php :

$config['uri_protocol'] = "REQUEST_URI";

My .htaccess file :

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

And when I call a view :
function index()
$data = array(
'title' => 'My Title',
'heading' => 'heading',
'message' => 'My Message',
'base_url' => $this->config->item('base_url'));

$this->load->view('navigation', $data);
$this->load->view('uses', $data);

My link on the view to another page :

<a href='".$base_url."mylinks'>Links</a>

And it actually works on my hosting server!!!!

Theme © iAndrew 2016 - Forum software by © MyBB