Let's suppose I have a website named
foo.com
I can access foo.com
and it runs the index.php
found in the root folder. My question is: how should I edit the vhost file to enable rewrite mod without enabling htaccess?
My goal is to be able to write
http://foo.com/bar/loremipsum/dolor
into my browser address bar and to run index.php regardless of the number of / characters in the url. My index.php would handle the parameters separated by /
How can I achieve this?
EDIT: vhost file:
<VirtualHost *:80>
ServerName myproject.com
ServerAlias www.myproject.com
ServerAdmin webmaster@localhost
DocumentRoot /opt/apps/myproject
<Directory /opt/apps/myproject>
# disable htaccess
AllowOverride None
# route everything to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EDIT: The problem, as the accepted answer suggests is that this host did not contain the line which turns the rewrite engine on. This line is present in the answer. Which solves the problem.