CodeIgniter Forums
two .htaccess, mod_rewrites ? redirect to controller method - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: two .htaccess, mod_rewrites ? redirect to controller method (/thread-35144.html)



two .htaccess, mod_rewrites ? redirect to controller method - El Forum - 10-20-2010

[eluser]coldfire82[/eluser]
First thing first: not a mod rewrite expert but it should be easy for experts here!

Hi,

I have two CI installations and both have different .htaccess files,

First .htaccess in root folder i.e.

http://mysite.com/

Second site & .htaccess in folder below (its temporary installation so dont bother why i have itSmile) i.e.

http://mysite.com/business/


First .htaccess does nothing instead of taking care of index.php in urls.
Here it is,
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

  RewriteCond %{QUERY_STRING} ^utm_source=(.*)
  RewriteRule ^$ index.php?/$1 [L]
</IfModule>

In Second, I want to write a rule so that I get

http://mysite.com/business/<business_id> e.g. http://mysite.com/business/1
TO
http://mysite.com/business/<controller>/<method>/<business_id> e.g. http://mysite.com/business/index.php/indexg/business_unit/1

I tried to use this @thread -> http://ellislab.com/forums/viewthread/77892/
as
Code:
# map mysite.com/user_name to mysite.com/ci_folder/controller/method/user_name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/business/
RewriteRule ^(.*)$ /business/index.php/indexg/business_unit/$1

BUT, the result was a 404 and does not redirect to

http://mysite.com/business/index.php/indexg/business_unit/1

Any help?

What if I dont have a ci_folder?


two .htaccess, mod_rewrites ? redirect to controller method - El Forum - 10-20-2010

[eluser]coldfire82[/eluser]
in essence i need simple solution for

Quote:http://mysite.com/newyork
instead of
Quote:http://mysite.com/business/index.php/indexg/business_unit/newyork

the solution at http://ellislab.com/forums/viewthread/77892/
is not working

I also have AUTO in config for uri_protocol


two .htaccess, mod_rewrites ? redirect to controller method - El Forum - 10-20-2010

[eluser]coldfire82[/eluser]
In firebug, I get the header location as

Code:
http://mysite.com/business/indexg/business_unit/index.php?/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/indexg/business_unit/index.php&/1

...


above, it repeated 21 times this,
Code:
indexg/business_unit/index.php?/
and browser gives error "The page isn't redirecting properly"

I am using

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


  RewriteCond %{QUERY_STRING} ^gclid=(.*)
  RewriteRule ^$ index.php?/$1 [L]
  
  RewriteCond %{QUERY_STRING} ^utm_source=(.*)
  RewriteRule ^$ index.php?/$1 [L]

  RewriteRule ^([^/]+)/?$ /business/indexg/business_unit/$1 [R]
</IfModule>



two .htaccess, mod_rewrites ? redirect to controller method - El Forum - 10-20-2010

[eluser]coldfire82[/eluser]
any one ?


two .htaccess, mod_rewrites ? redirect to controller method - El Forum - 10-22-2010

[eluser]coldfire82[/eluser]
[quote author="coldfire82" date="1287601960"]in essence i need simple solution for

Quote:http://mysite.com/newyork
instead of
Quote:http://mysite.com/business/index.php/indexg/business_unit/newyork

the solution at http://ellislab.com/forums/viewthread/77892/
is not working

I also have AUTO in config for uri_protocol[/quote]

Any help in getting this(above) done?