Welcome Guest, Not a member yet? Register   Sign In
Removing the ? from path while using htaccess + QUERY_STRING
#1

[eluser]Rich Hauck[/eluser]
Wondering if someone could share an htaccess file that removes both index.php and the question mark (?) from a site path while using uri_protocol of QUERY_STRING.

Here's my config.php:

$config['uri_protocol'] = "QUERY_STRING";
$config['url_suffix'] = "";

Here's my current htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]
</IfModule>

I've been struggling with this for a few days now (see this forum post) and am hoping I'm closer by asking this question.
#2

[eluser]xwero[/eluser]
Because a question mark is an meta character in regex i guess you have to escape it.

index.php\?
#3

[eluser]Rich Hauck[/eluser]
Weird.

I tried that, and if I navigate to site.com/ci/?page it's fine, but if I try to navigate to site.com/ci/page it seems to redirect me to site.com and breaks all file/image references on the page.
#4

[eluser]ELRafael[/eluser]
[quote author="Rich Hauck" date="1190229810"]Wondering if someone could share an htaccess file that removes both index.php and the question mark (?) from a site path while using uri_protocol of QUERY_STRING.

Here's my config.php:

$config['uri_protocol'] = "QUERY_STRING";
$config['url_suffix'] = "";

Here's my current htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]
</IfModule>

I've been struggling with this for a few days now (see this forum post) and am hoping I'm closer by asking this question.[/quote]

Maybe now i understood better our question.

You need this kind of url
www.site.com/controller/method and not this: www.site.com/index.php/controller/method, right?

But what i didn't understand, is why you want uri_protocol = query_string... change to auto and in the .htaccess remove the ?/$1
Code:
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

have you tried this?
#5

[eluser]Rich Hauck[/eluser]
Auto won't work on this server Sad
#6

[eluser]ELRafael[/eluser]
In my webserver too...

so, my .htacces is about this:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

and my /config/config.php:
Code:
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'        Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'        Uses the REQUEST_URI
| 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol']    = "REQUEST_URI";

i hope works for you...
#7

[eluser]Rich Hauck[/eluser]
Tried it, and I get "The URI you submitted has disallowed characters." when attempting site.com/ci/?page

If I try site.com/ci/page Apache gives me a 404.
#8

[eluser]esra[/eluser]
This seems to work on a site setup for query strings when the uri protocol setting is set to AUTO. I would appreciate knowing if it does not work in your case.

Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]




Theme © iAndrew 2016 - Forum software by © MyBB