• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove "main" from current_url()?

#1
[eluser]Radiart[/eluser]
I use function current_url()

And the result is:

http://localhost/break/main/news/27501

But I want:

http://localhost/break/news/27501

#2
[eluser]SPeed_FANat1c[/eluser]
you can use uri routing http://ellislab.com/codeigniter/user-gui...uting.html

But I guess you are a beginner and if I were you I would try to avoid this, because it is confusing if you have no experience (at least for me it is).

#3
[eluser]Madmartigan1[/eluser]
Radiart, are you simply trying to manipulate the url string or the url itself?

current_url() basically just returns the current url, as you would expect. Nothing more.

Code:
function current_url()
    {
        $CI =& get_instance();
        return $CI->config->site_url($CI->uri->uri_string());
    }

#4
[eluser]Radiart[/eluser]
In URL bar in web browser I see this:

http://localhost/break/news/27501

But when I use current_url() I see this

http://localhost/break/main/news/27501

On all my website I don't see "main" but when I use current_url() suddenly I see "main"

I just want to get current link same like in URL bar.

Maybe I must change something in my .httacces file?

Code:
RewriteEngine on
RewriteCond $1 !^([a-zA-z0-9/])
RewriteRule ^(.*)$ index.php [L]
RewriteCond $1 !^(index.php|img|board|uploads|css|js|tinymce|system)
RewriteRule ^(.*)$ index.php/$1 [L]

#5
[eluser]Madmartigan1[/eluser]
That's really odd...

What happens when you use this?:


site_url($this->uri->ruri_string())

#6
[eluser]Radiart[/eluser]
[quote author="Madmartigan1" date="1293681914"]That's really odd...

What happens when you use this?:


site_url($this->uri->ruri_string())[/quote]

http://localhost/break/main/preview/news/27501

#7
[eluser]Madmartigan1[/eluser]
That's strange. Which bits of that url are directories and which bits are controllers methods and params?

Can you explain the url a bit?

Can you post your routes.php?

#8
[eluser]Radiart[/eluser]
[quote author="Madmartigan1" date="1293682742"]That's strange. Which bits of that url are directories and which bits are controllers methods and params?

Can you explain the url a bit?

Can you post your routes.php?[/quote]

URL

http://localhost/break/news/27501

http://localhost - Everything I testing on local machine I use EasyPHP 5.3.3
break - main folder where I have aplication and system folders
news - function in class preview
27501 - id



ROUTES

$route['default_controller'] = "preview/index";
$route['scaffolding_trigger'] = '';

/* PORTAL */
$route['logowanie'] = "portal/logowanie";
$route['rejestracja'] = "portal/rejestracja";
$route['logout'] = "portal/logout";
...

/* LIST */
$route['polecamy'] = "lista/polecamy";
$route['polecamy/(:any)'] = "lista/polecamy/$1";
$route['newsy'] = "lista/newsy";
$route['newsy/(:any)'] = "lista/newsy/$1";
...

/* PREVIEW */
$route['news/(:any)'] = "preview/news/$1";
$route['wydarzenie/(:any)'] = "preview/wydarzenie/$1";
$route['artykul/(:any)'] = "preview/artykul/$1";
...

/* PANEL */
$route['panel'] = "panel/index";
$route['panel/partnerzy'] = "panel/partnerzy";
$route['panel/edycja/partnera'] = "panel/edycja_partnera";
$route['panel/update/partnera'] = "panel/update_content";
$route['panel/strony'] = "panel/strony";
...

$route['(.*)'] = "preview/page/$1"

#9
[eluser]Madmartigan1[/eluser]
Quote:In URL bar in web browser I see this:

http://localhost/break/news/27501

But when I use current_url() I see this

http://localhost/break/main/news/27501

Where is "main" coming from? This just makes no sense to me, I don't see it anywhere.

If what you're saying is true, then I have no idea.

#10
[eluser]Radiart[/eluser]
Ok I start searching "main" and I found the problem

In config.php there was:

$config['index_page'] = "main";

I remove it and now it's working

Thx =)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.