1

Here's what I want to do: I'm using CodeIgniter, so all URLs are in the form of http://example.com/index.php/controller/function. However, the script I've written is a essentially a glorified link shortener with some built-in statistics functions, so I want all of the URLs to be in the form of http://example.com/link. However, I would also like the script's admin panel to be available at http://example.com/admin/. I adapted the CodeIgniter "remove index.php from URLs" example .htaccess to fit my situation, and it works correctly on my localhost (EasyPHP 5.3.9), but when I upload it to the production server (HostGator), all of the requests for the administration panel are being handled like a regular link and passed to the link controller (index.php/redirection/link) instead of the admin controller (index.php/admin). Here's my .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes access to the system folder by users.
    # Additionally this will allow you to create a System.php controller,
    # previously this would not have been possible.
    # 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php/$1 [L]

    # When your application folder isn't in the system folder
    # This snippet prevents user access to the application folder
    # Submitted by: Fabdrol
    # Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php/$1 [L]

    # Checks to see if the user is attempting to access the administration panel,
    # and if so sends the request to the admin controller
    RewriteRule ^admin/?$ index.php/admin/ [L]
    RewriteRule ^admin/([^.]+)/?$ index.php/admin/$1 [L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the redirect controller
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/redirection/link/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

Is there something I'm doing wrong? Any help or suggestions would be appreciated!

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
stevenmirabito
  • 161
  • 1
  • 2
  • 6
  • 1
    Do you know if the "AllowOverride" option is set correctly that you are actually allowed to use htaccess files to the full potential ? https://httpd.apache.org/docs/2.0/mod/core.html – Richard Jun 07 '12 at 02:25
  • @Richard No, I don't know, and it doesn't seem to be listed in phpInfo. I will contact HostGator about this tomorrow to see if it's something on their end (I actually didn't think about that!). Still, if anyone sees any other issues, please let me know! – stevenmirabito Jun 07 '12 at 02:51
  • [Administration panels are off topic](http://serverfault.com/help/on-topic). [Even the presence of an administration panel on a system,](http://meta.serverfault.com/q/6538/118258) because they [take over the systems in strange and non-standard ways, making it difficult or even impossible for actual system administrators to manage the servers normally](http://meta.serverfault.com/a/3924/118258), and tend to indicate low-quality questions from *users* with insufficient knowledge for this site. – HopelessN00b Mar 16 '15 at 01:46

2 Answers2

1

Remove the below lines from .htaccess

RewriteRule ^admin/?$ index.php/admin/ [L]
RewriteRule ^admin/([^.]+)/?$ index.php/admin/$1 [L]

Add this two line routes.php

$route['admin']="<directory_name_in_contollers>/<controller_name>";
$route["admin/(:any)"]="<directory_name_in_contollers>/$1";

Example:

$route['admin']="admin/welcome";
$route["admin/(:any)"]="admin/$1";

Here welcome.php is a controller places at application\controllers\admin\welcome.php

mrsrinivas
  • 111
  • 3
-1

Below the command "RewriteEngine On"put "RewriteBase /" or "RewriteBase /app_name/" if your application is in a subdirectory "app_name".

Hope that helps.

Alfradique