I added this rule to my (htaccess) file on my root web server so that should anyone try to access lets say /web server/test then index would take the 'test' input as string but it is not working it keeps on saying error 404 not found.
My code is below:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
Are there any faults in this?
Below is my apache2 conf file.... As I get error 500 after changing my settings to override all.
Now I am getting error 500 ... so that I can provide more information... below is my htaccess file code
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine On
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
And my apache2.conf file.....
<Directory />
Options FollowSymLinks
AllowOverride All
#Require all denied
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
two key points you need attention .
ensure your root directory can be overwrite by apache , please check the apache configuration , correct setting by below:
<Directory />
Options FollowSymLinks Multiviews
#AllowOverride none
AllowOverride All
Order allow,deny
Allow from all
# Require all denied
</Directory>
check your rewrite rules and ensure them can work. On your case i test following rules and work fun on my local.
RewriteEngine On
RewriteRule ^(\w+)$ /index.php?page=$1 [L]
Hope this can help you!
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.
Slim PHP keeps on giving me a 404 Not Found, whenever accessing either the index.php itself, or any of the REST services (e.g. index.php/MyService)
I suspect that my problem is related to my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Directory structure:
My Slim index.php is located under
/var/www/api/v1/index.php
My apache2.conf:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I can execute any other PHP script just fine (e.g. /api/v1/test.php)
On Live server, to resolve 404 error when trying to access any page, changed below setting in httpd.conf
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But on next day it gets reset to below
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Really hoping that it was going to work, but no go. This is what .htaccess looked like after I changed the permalink option:
<Directory />
Options +FollowSymLinks
AllowOverride All
</Directory>
<Files .htaccess>
order allow,deny
deny from all
</Files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The pages are still not accessible. Changing AllowOverride None to AllowOverride All works, but it resets again to default setting somehow.
404 page not found error appears often even after changing httpd.conf and .htaccess.
Note: mod_rewrite is already installed
I was making a .htaccess file to run a framework that I was testing, but when I tried to access to my localhost, the folder where is located the framework's files didn't show up.
If I try to access, requesting the localhost/my_hidden_folder/ this fires a 500 error, internal server error.
This behaviour is result of some wrong configuration with my apache|.htaccess, I'm pretty sure because the same .htaccess in another server works fine.
Here is my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
And here is my default file from /etc/apache2/sites-available:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/entrega2>
AllowOverride All
</Directory>
<Directory /var/www/unlp>
AllowOverride All
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Both folders, /var/www/unlp and /var/www/entrega2 have the same .htaccess file, and both are hidden.
The most basic redirect in the .htacces file doesn't work, in my localhost, but in the server works. Maybe I have a module disabled?
Is there a +FollowSymlinks in .htaccess? This usually does the 500 error on Linux systems that have already activated the option or on Windows.
Try to run phpinfo() to make sure the mod-rewrite is activated.
Create simple php file in your web root folder, which contains:
<?php
phpinfo();
?>
i have the resources shared with another project. The pictures of the products i will show, are stored in a folder out of my new project for which im using symfony...
In my symfony project, in the /web/images folder, i created a symbolic link to the folder where my pictures are stored. im sure the permissions of every file and folder under the pictures folder pointed by the symlink are setted 777, anyone can access to them.
Everything worked fine until i enabled the mod rewrite of apache. Pictures on the /web/images folder were shown perfectly, buy anything accessible through the symlink wasn't shown. I immediately thought the symlink was the reason of this behavior, and i checked my apache configuration for the site. Also, reading on symfony, i examined the .htaccess file under the /web folder and added the line:
Options FollowSymLinks
This didn't work either.
Here's my site configuration:
#<VirtualHost mydomain.com>
<VirtualHost *:80>
#ServerAdmin webmaster#localhost
ServerAdmin admin#mydomain.com
ServerName mydomain.com
ServerAlias www.mydomain.com
#DocumentRoot /var/www
DocumentRoot /srv/www/mydomain.com/public_html/
<Directory />
Options FollowSymLinks
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
#<Directory /var/www/>
<Directory /srv/www/mydomain.com/public_html/>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
#AllowOverride None
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#Options +ExecCGI -MultiViews +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
#ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog /srv/www/mydomain.com/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
#CustomLog ${APACHE_LOG_DIR}/access.log combined
CustomLog /srv/www/mydomain.com/logs/access.log combined
Alias /sf /home/victor/projects/vitoquen/tienda/lib/vendor/symfony/data/web/sf
<Directory "/home/victor/projects/vitoquen/tienda/lib/vendor/symfony/data/web/sf">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from All
</Directory>
#Alias /doc/ "/usr/share/doc/"
#<Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# #AllowOverride None
# AllowOverride All
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#</Directory>
</VirtualHost>
And here's my .htaccess:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Any suggestions?? thanks for taking the time of reading and answering!!!
EDIT:
I tried the Znarkus' solution, and didnt work! this, i think, can mean that the symlink was not the problem.
Files in the pictures folder are stored without extention. Because of than, i cant use the image_tag() helper of symfony, which appends .png by default to the file name if no extention is given... this is the way im displaying images in my template:
if (strcmp($producto->foto, "SI") == 0) {
echo '<img src="/images/productos/'.$producto->id.'_muestra" width="102" height="84" alt="Imagen de muestra"/>';
} else {
echo '<img src="/images/no_picture.jpg" width="102" height="84" alt="Imagen de muestra"/>';
}
The strange thing is that /images/no_picture.jpg is shown perfectly. Thanks again for any help you can give me!!!
Symfony problably doesn't support symlinks. Try doing mount --bind instead, which should be transparent to the application.
Your updated question: You must have an extension for the <img /> tag to work.