Welcome Guest, Not a member yet? Register   Sign In
Problem with url helper functions, SOMETIMES
#1

[eluser]CroNiX[/eluser]
Im not sure whats going on but on some pages when I use url helpers like base_url(), site_url() and anchor() they don't seem to work properly on some pages.

in config.php:
Code:
config['base_url'] = 'http://www.mysite.com/appname/';

If I do
Code:
echo anchor('controller/method');
it creates http://www.mysite.com/appname/controller/method as the href, but when I click on it it goes to http://www.mysite.com/controller/method.

It works on some pages, but not others, so Im kind of confused.

Heres the .htaccess from www.mysite.com/appname

RewriteEngine On

# Handle the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

I had to add the ? after index.php to get it working on the live server.

Any help would be appreciated.
Thanks!
#2

[eluser]TheFuzzy0ne[/eluser]
First of all, try clearing your cache. Secondly, I'd suggest a:

Code:
RewriteBase /appname/

As if I understand correctly, the rewrite rule is rewriting the rule according to the web root, not the subdirectory. I'm probably wrong though.
#3

[eluser]Thiago Luiz[/eluser]
I'm not sure if this is correctly but into .htaccess try do put the name of your controller in a RewriteRule to the request be redirect to the index.php of your aplicattion. Look like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheet|javascript|robots\.txt|css|pdf)
RewriteRule ^(ControllerNameOne.*)$ /CodeIgniter/index.php/$1 [NC]
RewriteRule ^(ControllerNameTwo.*)$ /CodeIgniter/index.php/$1 [NC]




Theme © iAndrew 2016 - Forum software by © MyBB