Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:36:30+00:00 2026-06-11T11:36:30+00:00

I am using CodeIgniter for my site and I want to shorten my URLs

  • 0

I am using CodeIgniter for my site and I want to shorten my URLs to look a lot nicer, but it doesn’t seem to work. I am using the htaccess method and this is my code below.

<IfModule mod_rewrite.c>

RewriteCond $1 !^(index\.php|(.*)\.swf|user_guide|profiles|images|min|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteEngine On

RewriteBase /gicfamily/

RewriteRule ^([a-zA-Z0-9]+)$ gallery?var=$1

I want the URL gicfamily.org/gallery?var=photos
to look like gicfamily.org/gallery/photos.

My config file looks something like this:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


$config['base_url'] = '';


$config['index_page'] = '';


$config['uri_protocol'] = 'AUTO';

$config['url_suffix'] = '';

$config['language'] = 'english';


$config['charset'] = 'UTF-8';


$config['enable_hooks'] = FALSE;


$config['subclass_prefix'] = 'MY_';



$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';


$config['allow_get_array']      = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger']   = 'c';
$config['function_trigger']     = 'm';
$config['directory_trigger']    = 'd'; // experimental not currently in use


$config['log_threshold'] = 0;


$config['log_path'] = '';

$config['log_date_format'] = 'Y-m-d H:i:s';

$config['cache_path'] = '';


$config['encryption_key'] = 'ksfkvjbskfbvskbvlbsbvsokbskdb';


$config['sess_cookie_name']     = 'gic_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'gic_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

$config['global_xss_filtering'] = FALSE;

$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;

$config['compress_output'] = FALSE;


$config['time_reference'] = 'local';


$config['rewrite_short_tags'] = FALSE;


$config['proxy_ips'] = '';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:36:31+00:00Added an answer on June 11, 2026 at 11:36 am

    I think you may be misunderstanding how routes and URLs work in CodeIgniter. Please see the following two pages that speak to how to use the routing features:

    http://codeigniter.com/user_guide/general/urls.html
    http://codeigniter.com/user_guide/general/routing.html

    The idea of the “parameter” is implied by the parameter’s placement in the URL structure. For example:

    /gallery?var=photos

    Would become

    /gallery/photos

    In this example each of these is called “segments” of the URL. gallery is segment #1 and photos is segment #2. The pattern always follows that segment #1 is the controller and segment #2 is the method. For your URL it would be: gallery is the controller, and photos is the method.

    If you want to pass any parameters you would append them on as additional segments to the URL like so:

    /gallery/photos/param1/param2

    This would accomplish the cleaner look you’re trying to accomplish.


    Update
    I didn’t mention in the answer that this replaces the .htaccess rewrites you’re trying to do. You’d keep these lines of the .htaccess:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter and .htaccess to rewrite the URLs but I want it to
CodeIgniter is brilliant but I'm using it to develop a site where users need
I've just built a site using codeigniter and mysql. It works great, but I
My site was developed using CodeIgniter and was working fine before but now it's
I'm building a site using CodeIgniter that largely consists of static content (although there
I am using codeigniter framework for my site and I have done two site
So I have made a simple site for a friend using codeigniter and grocery
I am planning a new website with codeigniter using wordpress. this site will contain
I'm using CodeIgniter + Zend libraries. I want to let users upload videos to
I'm writing an admin section to a site using CodeIgniter. I am writing an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.