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 ?
Related
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 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 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 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?
I purchased yesterday a virtual private server with PHP version 5.3.3
Then i upgraded my php version to 5.4.22
Now the htaccess doesnt functional normally.. It doesn't do anything.
What i tried:
I did this in my httpd.conf
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
And it didn't work so i tried this in my .htaccess:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
SetHandler x-httpd-php54
</FilesMatch>
And this doesn't work either.
If i create a page with <?php phpinfo() ?> and i check the loaded modules i see that mod_rewrite is loaded.
My .htaccess
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$">
Order Allow,Deny
Deny from all
</FilesMatch>
RewriteEngine on
RewriteRule ^d/(.*)$ delete.php?img=$1 [L]
RewriteRule ^i/(.*)$ i.php?img=$1 [L]
RewriteRule ^e/(.*)$ editor.php?img=$1 [L]
RewriteRule ^u/$ /u/index.php?img=$1
RewriteRule ^([a-zA-Z0-9]*)$ getimage.php?image=$1
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.(gif|jpeg|png|bmp|jpg) http://(ip)/6j5o [NC,L]
ErrorDocument 400 http://(ip)/404.php
ErrorDocument 401 http://(ip)/404.php
ErrorDocument 403 http://(ip)/404.php
ErrorDocument 404 http://(ip)/404.php
ErrorDocument 500 http://(ip)/404.php
Any ideas? (My server is a Centos 6 64bit)
Your Apache config is at /etc/httpd/conf/httpd.conf. Make sure this line is not commented out
LoadModule rewrite_module modules/mod_rewrite.so
Now, head over to /etc/httpd/conf.d and look at the config for your site (I hope you've made your own sitename.conf in here). You should have something like this (yours will probably differ a fair amount, this is from a server hosting one site)
<VirtualHost *:80>
DocumentRoot /var/www/html/mydir
ServerName my.domain.name
ServerAlias my.domain.name
ErrorLog logs/mydomain
CustomLog logs/mydomain common
<Directory "/var/www/html/mydir">
Allow from all
Options +FollowSymLinks
</Directory>
</VirtualHost>
Make sure you use full path names to your site's root directory.