问题
I have been developing using Bitnami MAMP stack 5.6.19 on my Macbook
I'm now ready to upload it to my server, but before that I want to remove the index.php from the site url and test it on my Mac so I can address any bugs.
I have tried changing the httpd-app.conf, httpd-prefix.conf as suggested on the Bitnami site, but no luck. I get a 404 error from the page.
Here is the httpd-app.conf
I change AllowOverrite
from None
to All
<Directory "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/htdocs">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfDefine USE_PHP_FPM>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://codeigniter-fpm"
</FilesMatch>
</IfDefine>
</Directory>
Here is the httpd-prefix.conf
I added DocumentRoot "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/htdocs"
and commented out the Alias's
DocumentRoot "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/htdocs"
#Alias /codeigniter/ "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/htdocs/"
#Alias /codeigniter "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/htdocs"
Include "/Applications/mampstack-5.6.19-0/frameworks/codeigniter/conf/httpd-app.conf"
In the codeigniter config I changed $config['index_page'] = 'index.php';
to $config['index_page'] = '';
I can't edit that the .htaccess file, cause I can't locate it and from what I understand Bitnami changed the app so you don't need to change .htaccess
回答1:
Add a .htaccess file in root folder and paste this code into it.
htaccess Module:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule>
Regards :)
回答2:
Use http://www.your-site.com
instead of index.php
, and, of course, replace your-site
with your website name.
来源:https://stackoverflow.com/questions/42090166/how-to-remove-index-php-from-codeigniter-on-bitnami-mamp-stack