Welcome Guest, Not a member yet? Register   Sign In
[solved]Virtual links aren't working while running site on a subdirectory

I have been using CI for a couple of web sites running on the root without much of an issue, but this time I'm working on one that needs to run on a subdirectory, let's call it "dir".

Now, I have the homepage loading fine under http://example/dir/ but internal links like /dir/something aren't working. They give me a server 404 message, not even a CI 404 message, so I assume the problem is with .htaccess

In fact, /dir/index.php/something works.

This is what I have on the .htaccess right on /dir/:

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I have also tried to change it to RewriteBase /dir/ but that didn't work.

Checking the manual, it could also be a routes.php issue.

I currently have:
$route['search'] = 'search';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

And I have tried to replace $route['(:any)'] with $route['dir/(:any)'] but that just made the homepage go 404, so this is probably the wrong place.

This is likely a very simple problem, but I can't for the life of me figure out what I'm doing wrong.

EDIT: Ok, the solution was simple: you have to add a specific mod_rewrite rule for /dir/ on the .htaccess under the root / and not in /dir/.

Theme © iAndrew 2016 - Forum software by © MyBB