Welcome Guest, Not a member yet? Register   Sign In
.htaccess help! Can't hide index.php on subfolder
#1

[eluser]solarolosonoio[/eluser]
hello

I need to put a site in a subfolder…

www.url.com/subfolder

and I need it to work like that.

It works with the index.php, like this

www.url.com/subfolder/index.php/controller1

but I just don't find the right .htaccess way to make it work without the /index.php/ on the URL.

I set the base url on the config file, like this:

Code:
$config['base_url'] = "http://www.url.com/subfolder";

Then.
With this on the .htaccess, for example:

Code:
RewriteEngine on

RewriteBase /subfolder

RewriteCond $1 !^(index\.php|img|asset)
RewriteRule ^subfolder/(.*)$ /index.php/$1 [L]

The default controller works, but for the rest I get a Not Found error!

Someone? (I'm desperate)

Thanks!
#2

[eluser]pickupman[/eluser]
If you have .htaccess in your subfolder (where it should be), you shouldn't need to use RewriteBase rule. Here's my .htaccess I use in a subfolder
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

You may have to clear your browser's cache, if it doesn't work. Or just reload the page a couple times. I use it this way, so I can work locally in a subfolder, and upload to root of a live site. Works on both.
#3

[eluser]solarolosonoio[/eluser]
[quote author="pickupman" date="1285109621"]If you have .htaccess in your subfolder (where it should be), you shouldn't need to use RewriteBase rule. Here's my .htaccess I use in a subfolder
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

You may have to clear your browser's cache, if it doesn't work. Or just reload the page a couple times. I use it this way, so I can work locally in a subfolder, and upload to root of a live site. Works on both.[/quote]

Thanks for your reply!

Thanks for clearing that out with the htaccess code. It is in the subfolder.

It works locally! with MAMP 1.9,
but live works only for the default controller,
for the rest of controllers now I'm getting a white page with the message: No input file specified.

Any ideas?
#4

[eluser]pickupman[/eluser]
After RewriteEngine On add back
Code:
RewriteBase /subfolder/

Note both forward slashes.
#5

[eluser]pickupman[/eluser]
Oh, are you using any special routes or HMVC? Also, don't forget the filename casing are not the same on windows as the are in Linux. Sometimes I have capitalized a file wrong, and it works in windows, but when I run it in linux, it doesn't exist.
linux.php != Linux.php
#6

[eluser]pickupman[/eluser]
Also, it seems this may be server config rather than CI. Change the error level in /application/config/config.php and set to log all errors. Reload page and check /system/logs/log-date.php. You may find the error in your logs.

There are several posts about this error relating to having a doc_root statement in your php.ini error. Do you have access to php.ini on your live server to check that? You may also want to check file permissions on the other controllers. Make sure they are chmodding to the same.

Do you have anything else in your .htaccess file?
#7

[eluser]solarolosonoio[/eluser]
[quote author="pickupman" date="1285113933"]Also, it seems this may be server config rather than CI. Change the error level in /application/config/config.php and set to log all errors. Reload page and check /system/logs/log-date.php. You may find the error in your logs.

There are several posts about this error relating to having a doc_root statement in your php.ini error. Do you have access to php.ini on your live server to check that? You may also want to check file permissions on the other controllers. Make sure they are chmodding to the same.

Do you have anything else in your .htaccess file?[/quote]

Thanks a lot, you're being very helpful…

I got it to work following solution number 2 from this article:
http://www.terencechang.com/2008/08/28/c...-apache-2/

Now it's midnight (Barcelona) and I need to sleep, but tomorrow I'll check back all these things you refer to,
to see if we can figure out why this happens…

Thanks again!




Theme © iAndrew 2016 - Forum software by © MyBB