I am a new user of Zend Server. For some reason Apache is not reading my htaccess file in the project folder. please check my settings:
Document root:C:\Program Files\Zend\Apache2\htdocs\
project folder: C:\Program Files\Zend\Apache2\htdocs\project1\website\
htaccess path: C:\Program Files\Zend\Apache2\htdocs\project1\website.htaccess
Example to of rewrite rule in htaccess:
RewriteRule ^([a-zA-Z0-9\-]*)-([0-9]*)-([0-9]*)\.php$ /project1/website/index.php?cat=$2&page=$3 [L]
changes in httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
<Directory "C:\Program Files\Zend\Apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
The index page is working fine
http:// localhost/project1/website/
You should go to httpd.conf file in your apchachi folder/conf and change AllowOverride none to AllowOverride ALL after restart apachi server.Hope it work.
Related
I know this question is asked a lot but I read all the questions related to this but they didn't solve my problem.
I just deployed a Symfony 3 web app and I followed the Symfony server configuration documentation just to find out that the www.domain.com displays the directory structure!
Here's the configuration that I used of file /etc/apache2/sites-available/site.com.conf:
<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>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
I can see the app when I go to www.domain.com/web and www.domain.com/web/app.php
I want to be able to visit www.domain.com and see the app.
Change the line:
AllowOverride None
to next one:
AllowOverride All
Remove section <IfModule mod_rewrite.c> And use standard Symfony's .htaccess file.
Also you need to set up PHP as module for your apache. Be sure to have uncommented line in http.conf that loads PHP module:
LoadModule php7_module libexec/apache2/libphp7.so
You are missing your DirectoryIndex app.php or DirectoryIndex dev_app.php contained in your directory tag. This will cause apache to load app.php if a file has not been requested.
https://httpd.apache.org/docs/2.0/mod/mod_dir.html
<Directory /var/www/project/web>
DirectoryIndex app.php
...
</Directory>
Also make sure mod rewrite is enabled.
a2enmod rewrite
You may have to use sudo.
One final note:
Options -MultiViews should be contained inside the <Directory> for use all the time and not just when mod_rewrite is enabled.
I have an instance running ubuntu in ec2. I have this .htaccess file :-
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This file is located inside the var/www/html folder. I am aiming to achieve loading of amazon-public-dns.com/index.php as amazon-public-dns.com/index. Now, I have tried these steps :-
1)
Creating the rewrite.conf in /etc/apache2/mods-enabled and in the file putting the line LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so. (Refer this answer)
2)
Running the command apache2 enable module rewrite. Also, in the file /etc/apache2/sites-available/000-default.conf and writing this in the end :-
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride All
Order allow,deny
allow from all
</Directory>
Note that this answer told to edit the default. But, since that file was not there in my case, I edited the 000-default.conf file.
I restarted apache as told. But the link amazon-public-dns.com/index gives me a 404 :( Please help me.
EDIT : I put some random junk in the htaccess file. But the index.php is not giving any 500 internal server error which means that the htaccess file is being ignored. Now in
https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles
, they say to enable htaccess edit this file - /etc/apache2/sites-available/default. BUT THERE IS NO SUCH FILE
following command works for me Great !
sudo a2enmod rewrite
sudo service apache2 restart
To check loaded modules
sudo apache2ctl -M
The default conf file /etc/apache2/sites-available/000-default.conf only work if its having a symlink in sites-enabled folder.
You have done all right steps. Its may be problem of sysmlink of sites-available folder. You can either create a symlink or update 000-default.conf with AllowOverride None to AllowOverride All inside file /etc/apache2/sites-enabled/000-default.conf
Today I faced this exact same problem on an ubuntu EC2 instance.
This worked for me:
Place your .htaccess configuration inside the <IfModule ..> directive:
<IfModule mod_rewrite.c>
RewriteEngine on
# your config here
</IfModule>
Not sure if /var/www/html is actually taken into account by the server.
Try changing this:
<Directory /var/www/html>
# your current implementation
AllowOverride All
</Directory>
for this one:
<Directory /var/www>
# your current implementation
AllowOverride All
</Directory>
This directive should already by there in your /etc/apache2/apache2.conf file.
If that does not work try to comment out your configuration, particularly the part that has the allow,deny and allow from all
<Directory /var/www>
# your current implementation
AllowOverride All
# Order allow,deny # try to comment this one out
# allow from all # also this one
</Directory>
Last but not least, check that the rewrite a2enmod module is loaded as suggested by #kamal-kumar and do not forget to restart you apache.
This worked for me, hope this helps someone else :)
I'm trying to rewrite from this url :
my domain/myapp/index.php?lang=es
to:
my domain/myapp/es/
with the following commands on the .htaccess file on the root:
RewriteEngine On
RewriteRule ^myapp/([a-zA-Z0-9_-]+)$ index.php?lang=$1
RewriteRule ^myapp/([a-zA-Z0-9_-]+)/$ index.php?lang=$1
but i didn't succeed
Your code has to work fine.
If you are using Apache server, make sure it is configured right:
Make sure this string is uncommented in httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
Make sure that there is:
AllowOverride All
in the Directory section instead of:
AllowOverride None
Section should look like:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
llow from all
</Directory>
With correctly configured server your .htaccess file works fine on my machine.
I'm trying to rework a legacy site by converting .html to .php for ease of future configuration. To accomplish this I'm working within the Apache server on my Mac OS X 10.9 machine. I've written an users.conf file uses mod_rewrite to remap the file names ending in .html to run as .php.
It was working fine when I left work yesterday, but today I get a "You don't have permission to access" error on the front end and a "[error] [client ::1] client denied by server configuration:" on the back end when I try to access localhost/~user/somefile.html.php All of the file permissions are set correctly (644 or 755 as appropriate).
Seems to only happen with files named somefile.html.php. Files named .html load fine and files named .php load fine. Apache version is 2.2.24.
Here is user.conf:
<Directory "/Users/user/Sites/mySite">
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/Users/user/Sites/mySite">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*\.html) $1.php
</Directory>
And here is relevant part of httpd.conf:
DocumentRoot "/Users/user/Sites"
LoadModule php5_module libexec/apache2/libphp5.so
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "/Users/user/Sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Maybe I've mixed together too many tutorials?
The answer was that I also needed to configure a virutal host.
This particular guide gave me the final clue I needed.
as in the title, this problem still persist, i've configured a virtualHost in apache2(on Ubuntu 12.04 on OVH Dedicated server), i've put a simple index.php in the base directory of my VirtualHost that contains this simple code:
<?php
echo "Hello world! ";
?>
but when i update my file by adding or removing code, i chek it by accessing the url http://test.xxxxx.ma:8082, the update is not applied, i've cleared my browser cache, used a new browser, i've cheked if mod_cache is enabled but it's not and i'm sur i'm working on the right directory, the new version of the file index.php is only served after a restart of apache2, my VirtualHost configuration is as follow :
<VirtualHost *:8082>
DocumentRoot "/var/www/vhosts/xxxxx.ovh.net/test"
ServerName test.xxxxx.ma
<Directory "/var/www/vhosts/xxxxx.ovh.net/test">
<IfModule sapi_apache2.c>
php_admin_flag engine on
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch +Indexes
allow from all
</Directory>
</VirtualHost>
try adding
# Disable Caching for Scripts and Other Dynamic Files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
in a .htaccess file