Reputation: 3953
.htaccess does not respond to RewriteRules. I have created a .htaccess file at the root of my project, and filled it with the below RewriteConditions
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)& index.php?url=1 [NC, L]
But I get false instead of true when I execute the below code in my index.php
<?php
var_dump(isset($_GET["url"]));
Below is what I have in my /etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I run my server from my folder located in my Home directory rather than /var/www/html
Also, when I access any part of the site localhost:8000/fishes
, it still loads the index.php
with false
displaying
I have been battling this but to no avail, please help guys, what could I be doing wrong.
Upvotes: 0
Views: 5151
Reputation: 3953
The reason why it does not work is because I am running PHP outside of apache /var/www/ directory, apparently if I want it to work outside there I will have to set it from/etc/apache2/apache2.conf
Upvotes: 1
Reputation: 4469
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.+) index.php?url=1 [NC, L]
Also, replace your Directory /
definition with the following:
<Directory />
Options Indexes FollowSymLinks -MultiViews
AllowOverride All
Require All Granted
Allow from all
</Directory>
Don't forget to restart Apache.
Make your home folder executable by apache. I assume you are using linux:
chmod a+x /home/myhome
Upvotes: 0