I have followed instructions in another SO post to enable mod_rewrite on EC2. I have this setup:
# Configure /var/www/html
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteRule ^/?jobs$ jobs.html [L]
However when I visit http://example.com/jobs it fails to rewrite. I have checked with phpinfo() and mod_rewrite is enabled in PHP. What else could be preventing rewrite?
Related
I am using WAMPServer as developping locally. I have a problem in redirecting pages with .htaccess
my .htaccess file is in root folder.
I have decommented the
LoadModule rewrite_module modules/mod_rewrite.so
rewrite_module is enabled in apache.
But it still does not work.
Note: it works in MAMP server as I checked but not in WAMP.
here is my .htaccess file.
# I tried both below solutions which found on internet but none of them worked
# - Options +FollowSymLinks -MultiViews
# - Options -Indexes -MultiViews
RewriteEngine On
RewriteRule ^home$ /SiteTemplate/index.php [L]
RewriteRule ^users$ /SiteTemplate/users.php [L]
RewriteRule ^addUser$ /SiteTemplate/registration.php [L]
in may httpd.conf it's like this.
# <Directory />
# AllowOverride none
# Require all denied
# </Directory>
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
Anybody can help please ?
I am sending a website live and I was getting a 500 internal Error.
So I have googled around and I have been able to find a solution.
I have added modifications to the code below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/public/index.php
RewriteRule ^(.*)$ /public/index.php/$1 [L]
</IfModule>
The issue is that, when I enter an URL such as www.app.com, I obtain www.app.com/public/index.php
Is there a way to update the .htaccess so that requests made to www.app.com will be redirected to www.app.com/public/index.php without showing /public/index.php in the URL?
Try modifying /etc/apache2/sites-available/default (default location on most Linux distributions, yours may be different).
Change AllowOverride None to AllowOverride All so you should have:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
Then restart apache with systemctl restart apache2.
I have a website made with Symfony 2.8.22 running with Apache 2.4.18. I have RewriteEngine activated in the virtualhost to not show the .php extension in the url. However I have 2 problems. The first one is I do get the .php extension via url. The second problem is I have a loop in the login page; once I input the credentials it reloads the same login page again, and again. That happens in Chrome and Firefox, however in Microsoft Edge that loop wont happen, it just follow to the next page.
Why is that?
Where's my virtualhost file:
<VirtualHost *:80>
ServerName ip.ip.ip.ip
DocumentRoot /var/www/html/website/web
<Directory /var/www/html/website/web>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule (.*)\.php $1 [R=301,L]
</IfModule>
</Directory>
<Directory /var/www/project>
Options FollowSymlinks
</Directory>
ErrorLog /var/log/apache2/error_website.log
CustomLog /var/log/apache2/access_website.log combined
</VirtualHost>
Thanks in advance.
Best regards.
I am not certain why you are trying to forcably remove .php from the web address bar. If you follow the Symfony Configuration guide it will give you an .htaccess file that works and will not display .php extensions:
<VirtualHost *:80>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /var/www/project/web
<Directory /var/www/project/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/project/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
I have a slight of problem.
I used simple php framework on github and have worked on it and added new functions and so on.
The framework that i have had help with is this:
https://github.com/panique/mini
Everything works perfectly in a MAMP environment, but now when i was going to test it on a live website and apache environment it does not work that good.
It obviously can read the index file since i point the directory to the directory that should be used for apache.
But when i am going to make a call to a controller (domain.com/login) it results in apache giving me :
"Not Found: The requested URL /login was not found on this server."
I have enabled rewrite with: service a2enmod rewrite, and i double checked and it is a Loaded module when looking in phpinfo().
The .htaccess file that is located in the "/var/www/html/php-project/public" directory(where i have pointed to in my virtual host file"
is the following:
# Necessary to prevent problems when using a controller named "index" and having a root index.php
Options -MultiViews
# Activates URL rewriting
RewriteEngine On
# Prevent people from looking directly into folders
Options -Indexes
# If the following conditions are true, then rewrite the URL:
# If the requested filename is not a directory,
RewriteCond %{REQUEST_FILENAME} !-d
# and if the requested filename is not a regular file that exists,
RewriteCond %{REQUEST_FILENAME} !-f
# and if the requested filename is not a symbolic link,
RewriteCond %{REQUEST_FILENAME} !-l
# then rewrite the URL in the following way:
# Take the whole request filename and provide it as the value of a
# "url" query parameter to index.php. Append any query string from
# the original URL as further query parameters (QSA), and stop
# processing this .htaccess file (L).
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
00-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.com
ServerAlias domain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/php-project/public
<Directory />
AllowOverride All
</Directory>
#DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
apache.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
AccessFileName .htaccess
I dont think the problem is within the php itself.
Thats why i don't added my code since its so many classes, but the code is as i said based on the framework in the beginning of the question.
Do any of you see any obvious problems in the conf's?
I have searched and searched for answers, but i don't seem to get it right. So i would really really appreciate some help.
Any questions, just ask on.
Thanks
Please follow the proper way of access rewrite module in apache2.
First enable the rewrite module in apache using below command-:
$ sudo a2enmod rewrite
Open the apache2.conf file
$ nano /etc/apache2/apache2.conf
Update the section
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Remove the section from 00-default.conf
Remove the below lines
<Directory />
AllowOverride All
</Directory>
Then finally restart your apache2.
$ sudo service apache2 restart
or
$ sudo /etc/init.d/apache2 restart
I am using Vagrant to build up a little Wordpress development VM. When I select permalinks (postname) then the page from an article doesn't load. However, when I select the standard link (i.e page id) all is working good.
I've used the service PuPHPet to build the VM.
My settings can be found here
I am using Wordpress 3.9.1 and Apache2
I've enabled mod_rewrite be executing:
a2enmod rewrite
And my .htaccess file from Wordpress is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /svisa/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /svisa/index.php [L]
</IfModule>
# END WordPress
it has the following permissions and ownership:
-rw-rw-rw- 1 vagrant www-data 248 May 30 14:52 .htaccess
My virtualhost file for the site (/var/www/svisa/) can be found here.
from my host computer, I browse to the site via adress: http://wpdev-vm/svisa/
where wpdev-vm is the name of the vm.
Does anybody know what I am missing to make the permalinks work?
I solved the problem myself.
In the default apache configuration, under /etc/apache2/sites-enabled, where mine is called 15-default.conf
This was declared under the document root:
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I had to change AllowOverride None to AllowOverride All. Thus you'll get the following:
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
After that, the permalinks started working.
The (correct) answer above says that you need to change AllowOverride None to AllowOverride All in your xxx-default.conf file found in the /etc/apache2/sites-enabled directory.
However, in my vagrant box (precise64) none of the allowOverride or <Directory /var/www/>... code was present to begin with in the default.conf file.
I ended up having to add all of it between the VirtualHost tags, like below:
<VirtualHost *:80>
# Other stuff
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And then having to restart apache, like below, for it to work.
sudo service apache2 restart