Welcome Guest, Not a member yet? Register   Sign In
Query String Rewrite for my site
#1

[eluser]Unknown[/eluser]
Now, I develop a site with CI. I use GET method for search because of opensearch for firefox.

Code:
index?message=keyword
I want to change address look like
Code:
index.php/message/keyword

I am not familiar with .htaccess. How should I write in .htaccess for that query string ?
#2

[eluser]designfellow[/eluser]
[quote author="saturngod" date="1249085906"]Now, I develop a site with CI. I use GET method for search because of opensearch for firefox.

Code:
index?message=keyword
I want to change address look like
Code:
index.php/message/keyword

I am not familiar with .htaccess. How should I write in .htaccess for that query string ?[/quote]

Hi,
METHOD 1
First add this into a .htaccess file to disable "index.php" appearing from url.
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Then, Open your routes.php file in application/config folder add the below given line

$route['index?message=(:any)'] = "index.php/message/$1";

METHOD 2

if the previous one doesn't work, then enable query string in your config.php file like this

$config['enable_query_strings'] = TRUE;

so, you will be able to use a url pattern like this

index.php?message=keyword
--------------------------------------------------------


Happy Coding
DesignFellow
#3

[eluser]Unknown[/eluser]
Mehtod 1 is not work. I am using XAMPP in Windows. After I do method 1, I can't call my js file and it also redirect to
http://localhost/ . So, I remove .htaccess file and then it's work javascript. But I have a error...

Code:
http://localhost/ornagai-ci/index.php?message=go

is not change to segment.




Theme © iAndrew 2016 - Forum software by © MyBB