Welcome Guest, Not a member yet? Register   Sign In
Can't configure 'remove index.php'
#1
Question 

Hi,

I just can't succeed in removing index.php  Huh. I googled, found many references to this, unsuccessful. I also search the forum, loads of posts, again without success.

The codeigniter directory is under /var.
  • I activated mod_rewrite (apache2 2.4.10)
  • I edited config.php: $config['index_page'] = ''; $config['uri_protocol'] = 'REQUEST_URI';
  • I created/modifdied .htaccess file as per instructed in the documentation (CodeIgniter 3.1.0), in three places: /var/www/html, /var/codeigniter
I still need to include index.php in the URL. In order to check if one of the three .htaccess is hit, I added garbage as the first line, but got no error.

Within all pages I read, I just can't find the right procedure. What is it ?

Thanks
Reply
#2

Please paste your .htaccess file content here.
Reply
#3

Hi Ayrese,

here we go.

In /var/codeigniter/application (not edited)

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

In /var/codeginiter

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

In /var/www

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

In /var/www/html

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

Thanks for your help.
Reply
#4

(This post was last modified: 10-19-2016, 07:39 AM by Wouter60.)

Put your .htaccess file in the same folder as index.php

My version:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# Prevent file browsing
Options -Indexes

In my config.php:
PHP Code:
$config['base_url']    = 'http://www.my-domain.com/' //example!
$config['index_page'] = '';
$config['uri_protocol']    = 'AUTO'
Reply
#5

Hi Wouter60,

tried your suggestion, but it still doesn't work. I added garbage at the beginning of the .htaccess file to get an error, but didn't get it, so that .htaccess file is not read I guess.

In a browser I get a 404 "The requested URL /wactrl was not found on this server." when I type http://cdesys.dlinkddns.com:180/wactrl

For sure wactrl is not in the /www/html directory. If I add index.php, all is well.
Reply
#6

If the garbage you added at the beginning of .htaccess is not producing an error that would tend to indicate the either mod_rewrite is not active or that .htaccess is not in the correct place. .htaccess should be in the same directory as index.php

You can view loaded apache modules by using the linux command console and the command apache2ctl -M Look for rewrite_module in the list that appears.
Reply
#7

(This post was last modified: 10-20-2016, 09:19 AM by planteg.)

Hi Dave,

from https://docs.bolt.cm/3.0/howto/making-su...cess-works I got the clue to check if Apache configuration enables .htaccess. In fact that was turned of. I changed this in apache2.conf:

Code:
<Directory "/var/www/htdocs">
   AllowOverride None

I changed None to All and got some results. The first .htaccess file accessed is in /var/www, and the second one is in /var/www/html. But then I get the AH00124 error: exceeded the limit of 10 internal redirects. Looks like it's lost somewhere in the forest. Having rewrites to log to level3, I learned that the server loops doing rewrite until the limit is reached.

On top of that, the rewrite is done wrong at the beginning:


Code:
strip per-dir prefix: /var/www/html/wactrl -> html/wactrl
applying patern '.' to uri 'html/wactrl'
rewrite 'html/wactrl' -> 'index.php'
add per-dir prefix index.php/ -> /var/www/index.php'
internal redirect with /var/www/index.php/ [INTERNAL REDIRECT]

Right after this, all of this is done again until the limit is reached.
As far as I understand, the URI from the received is /var/www/html/wactrl, where wactrl is the controller name. Once edited, that should become /var/www/html/index.php/wactrl right ? But it does not. What is wrong ?

And why is there a loop inside /var/www ?

EDIT ON October 20th

Finally made it work. The problem was the RewriteRule. I changed it to:
Code:
RewriteRule html html/index.php

Then /var/www/html/wactrl is changed to /var/www/html/index.php/wactrl

In short RewriteRule line is:[img]file:///Desktop/regex.jpg[/img]

RewriteRule SearchExpression ReplaceExpression

where SearchExpression is the part of the URI to be replaced by ReplaceExpression. This is the short story because both expression can use regular expression.

If you wish to test what you need, go https://regex101.com/ You can test drive your expressions live until you are satisfied. A screen shot is attached.

Thanks

Attached Files Thumbnail(s)
   
Reply




Theme © iAndrew 2016 - Forum software by © MyBB