5
votes

When I run CI project in the browser, using localhost/hr, it redirects me to localhost/dashboard/.

Searched different solutions but didn't get it working. here is my .htaccess file in "htdocs/hr" folder

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Note: There is no .htaccess file in htdocs folder.

When i remove/rename index.php file and access to htdocs it gives me error.

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. 

What am i doing wrong, how to get it working?

Screenshot of my htdocs/hr folder is bellow

enter image description here

2
what is there in your route.php - Snm
$route['default_controller'] = "site"; $route['404_override'] = ''; - Noman Ali
after RewriteEngine On put RewriteBase /hr/ - Kamran

2 Answers

7
votes

You need to set RewriteBase in your .htaccess file in your folder, which is in your case ci.

So you would currently have

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

You should change it to

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ci/

And that's it. It will work now.

2
votes

Have a look at RewriteBase directive and then try this:

RewriteEngine on
RewriteBase /hr/

RewriteCond %{REQUEST_URI} !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Plus, you need to make sure that Apache's rewrite module is enabled:

# Check if it's enabled:
apachectl -M | grep rewrite

# You might need sudo here:
a2enmod rewrite

# On platforms that a2enmod is not available, you need 
# to open up your httpd.conf file and uncomment the line
# that looks like this:
LoadModule rewrite_module libexec/mod_rewrite.so