简体   繁体   中英

How to remove index.php from codeigniter on Bitnami MAMP stack

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

使用http://www.your-site.com代替index.php ,当然,用您的网站名称替换your-site

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM