Remove index.php using server config (not .htaccess) |
[eluser]Unknown[/eluser]
According to the Apache documentation (below), it’s not advised to use .htaccess files if you have access to the server’s config file. I have said access and I’ve tried to apply the rules, as found in the CI documentation, to both the apache2.conf and /sites-available/default (Debian uses this file and I think many other distros do not). Has anyone hidden index.php like this? http://httpd.apache.org/docs/2.2/howto/h....html#when http://ellislab.com/codeigniter/user-gui.../urls.html
[eluser]WanWizard[/eluser]
For apache, it doesn't matter if your rewrite rules are in your .htaccess or in the virtualhost definition. You define them the same, and they work the same. So if it works in .htaccess, it works in a VirtualHost definition. The reasoning behind this is that using a .htaccess might be a potential security risk (it can be accessed by code), and it does have a performance hit (if you enable it, every page request will traverse your folder structure looking for the .htaccess file).
[eluser]Unknown[/eluser]
Ok I got this working, as you mentioned, by applying the very same rule inside the <virtualhost *:80> bracket (I thought I had tried this before but either messed it up or only did in the apache2.conf). So to anyone stumbling upon this in the future (running a debian server) you can hide index.php, without using .htaccess, by adding the following to /etc/apache2/sites-available/default <Directory /path/to/documentroot> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all #Remove index.php from URL in CI RewriteEngine on RewriteCond $1 !^(index\.php|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] </Directory> |
Welcome Guest, Not a member yet? Register Sign In |