0

I have a CodeIgniter install running in our root web directory that I copied into a subdirectory called /dev... I edited the config/config.php file to reflect the change so it is now like this:

$config['base_url']  = 'http://mysite.com/dev';
$config['sbase_url']     = 'https://mysite.com/dev';
$config['default_email'] = 'noreply@mysite.com';
$config['site_url']  = 'http://mysite.com/dev';

This is my .htaccess file:

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

When I hover over any links on the site they are correct, for example the contact us page link reads www.mysite.com/dev/contact but when I click any of the links I get a 404 error...

Is there something common I am missing?

Yan Berk
  • 14,328
  • 9
  • 55
  • 52

1 Answers1

3

Enable FollowSymlinks & add a ./ in front of index.php in your RewriteRule:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # block hidden directories
  RewriteRule "(^|/)\." - [F]

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

Also, I would leave blank $config['base_url'] = ''; & use the base_url() url helper when constructing links instead, which makes moving environments easier (e.g. subdir'd dev & root-level production).

... and of course, insure that ModRewrite is enabled in your Apache config.

sekati
  • 535
  • 5
  • 12
  • That didn't help... the default controller shows up, i.e. www.mysite.com/dev resolves the index page but if you try to go to any other page like www.mysite.com/dev/about it 404's –  Jul 08 '12 at 03:05
  • Are you quite certain ModRewrite is enabled on your Apache server? – sekati Jul 08 '12 at 03:13
  • Well the root version of the site works fine, I have an .htaccess file there to remove the index.php from the URL and it works. –  Jul 08 '12 at 03:16
  • Try adding `RewriteBase /dev/` below `RewriteEngine On` to the .htaccess - I believe that should resolve it. – sekati Jul 08 '12 at 03:19
  • Doesn't seem to have worked... I don't have access to the httpd.config file, is there a way i can test for mod_rewrite with php? –  Jul 08 '12 at 03:21
  • Yes, you can create an `info.php` somewhere which contains: `` - look at the _Loaded Modules_ section and see if it lists `mod_rewrite`. – sekati Jul 08 '12 at 03:23
  • This is a clients remote server BTW, I don;t usually have mod_rewrite issues on my server. –  Jul 08 '12 at 04:06
  • Once you get mod_rewrite module enabled properly on your clients server my answer should get you up & running. – sekati Jul 09 '12 at 03:48