Welcome Guest, Not a member yet? Register   Sign In
Routes and GET Query.
#1

[eluser]pisio[/eluser]
How I can make GET doesn't like this
http://localhost/ci/subtitles/search?subs=sads
and like this
http://localhost/ci/subtitles/search/subs/sads
or
http://localhost/ci/subtitles/search/sads


I try to add in
./system/application/config/routes.php :
$route['subtitles/search/(:any)'] = "/subtitles/search/$1";

But doesn't work.
How I can make it ?
searach_view.php

Code:
<?php
$lang = $this->lang->language;

echo form_open('/subtitles/search/',array('method' => "get"));
echo $lang['search'].form_input(array('type'=>'text', 'name' => 'subs'));

echo form_input(array('type'=> 'submit','value'=>$lang['go']));
echo form_close();

?>


Edit:
I think that can be made with .htaccess mod_rewrite ?????
#2

[eluser]WanWizard[/eluser]
Looks like you're constructing the URL yourself in your form. Why not use the 'post' method, and accept a URL like http://localhost/ci/subtitles/search/subs/sads directly?
#3

[eluser]pisio[/eluser]
[quote author="WanWizard" date="1282009785"]Looks like you're constructing the URL yourself in your form. Why not use the 'post' method, and accept a URL like http://localhost/ci/subtitles/search/subs/sads directly?[/quote]
More impression. And If i can make it with GET I'll make it with redirect ...
#4

[eluser]WanWizard[/eluser]
Sorry, I don't understand what you're trying to say...
#5

[eluser]pisio[/eluser]
[quote author="WanWizard" date="1282010159"]Sorry, I don't understand what you're trying to say...[/quote]
If I can not do it with GET to go / subtitle / search / what is demanded to do what you offered me a redirect.No afraid of too many impressions
#6

[eluser]WanWizard[/eluser]
You can try this rewrite
Code:
Rewritebase /ci/
RewriteCond $1 ^subtitles/search/$
RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
RewriteRule ^$ subtitles/search/subs/%1 [L]
#7

[eluser]pisio[/eluser]
[quote author="WanWizard" date="1282011132"]You can try this rewrite
Code:
Rewritebase /ci/
RewriteCond $1 ^subtitles/search/$
RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
RewriteRule ^$ subtitles/search/subs/%1 [L]
[/quote]
Code:
<IfModule mod_rewrite.c>

        Options +FollowSymLinks
        RewriteEngine on
        # Send request via index.php (again, not if its a real file or folder)
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d

        <IfModule mod_php5.c>
                Rewritebase /ci/
                RewriteCond $1 ^subtitles/search/$
                RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
                RewriteRule ^$ subtitles/search/subs/%1 [L]

                RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>                                    
</IfModule>

error 500
#8

[eluser]WanWizard[/eluser]
This one works for me:
Code:
RewriteCond $1 ^subtitles/search$
RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
RewriteRule ^(.*)$ $1/subs/%1 [L]

This requests
Quote:http://test.catwoman.exite.local/subtitl...teststring

gives a $this->uri->uri_string of
Quote:/subtitles/search/subs/teststring

Note: this rewrite has to be placed before the rewrite to index.php, otherwise the first condition will never match.
#9

[eluser]pisio[/eluser]
Ok, at the last this must be look :
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 ^subtitles/search$
RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
RewriteRule ^(.*)$ $1/subs/%1 [L]


RewriteRule ^(.*)$ index.php/$1 [L]
?
#10

[eluser]Clooner[/eluser]
[quote author="pisio" date="1282062987"]Ok, at the last this must be look :
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 ^subtitles/search$
RewriteCond %{QUERY_STRING} ^subs\=([^&]+)$
RewriteRule ^(.*)$ $1/subs/%1 [L]


RewriteRule ^(.*)$ index.php/$1 [L]
[/quote]
Never thought of this but it is a very clean way to get rid of those get parameters Big Grin Nice




Theme © iAndrew 2016 - Forum software by © MyBB