In my .htaccess file this piece of code is present:
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
php_value max_execution_time 200
php_value output_buffering 4096
php_flag display_errors On
php_value session.gc_maxlifetime 1000
php_value session_set_cookie_params 1000
php_value session.bug_compat_42 off
php_value session.bug_compat_warn off
php_value session.cookie_httponly true
Options FollowSymLinks
Options -Indexes
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors On
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)
RewriteRule .* - [F]
<ifModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header append X-FRAME-OPTIONS "SAMEORIGIN"
Header set X-Content-Type-Options: "nosniff”
</ifModule>
Header append X-FRAME-OPTIONS "Deny"
RequestHeader unset X-Forwarded-For
<Files phperrors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files phpaccess.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files ~ "^\w+\.(gif|jpe?g|png|doc|pdf)$">
order deny,allow
allow from all
Satisfy All
</Files>
ErrorDocument 404 http://example.com/content/error.php
And I think the code is redirecting every unwanted/suspicious URL call to error page.
I have created a sub folder inside the domain and I want to call it like this in URL: http://example.com/sub_folder but it is redirecting me every time to error page (http://example.com/content/error.php).
How can I include the rule in the .htaccess file, that I will be able to load the sub folder's content?
Thanks
Related
On chrome (tried many devices)
My (Angular) web app is sitting on a subdomain and referencing media in a folder in the main domain using https. When using http to access the web app, all media referenced load well but when using https to access the web app, the media don't load and on inspection, media fetch are showing 504 error.
But on Firefox, everything is fine.
Please what could be wrong? Could be the .htaccess configuration or something?
Chrome Developer Tool (Network Tab)
enter image description here
My .htaccess file
`
RewriteEngine on
<FilesMatch "\.(mp4)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Max-Age "3600"
</IfModule>
</FilesMatch>
# RewriteCond %{HTTPS} !on
# RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.html [L,QSA]
</IfModule>
# RewriteRule ^.*$ /index.php [L,QSA]
#for passing HTTP AUTHORIZATION header
CGIPassAuth On
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 128M
php_value post_max_size 120M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
php_value upload_max_filesize 120M
php_flag zlib.output_compression On
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 128M
php_value post_max_size 120M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
php_value upload_max_filesize 120M
php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php80” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php80___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
`
I have searched the internet for solution but clear cut answer
i can't navigate an open the other page of my website when it depolyed to the server and it display to me an error page with this message :
404 Not Found The resource requested could not be found on this server!
I just uploaded my project Symfony application from my pc (localhost) to my server or CPANEL.
i configured the database and i created .htaccess into public_html like so public_html/.htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L]
php_flag display_errors On
php_value max_execution_time 300
php_value max_input_time 300
php_value max_input_vars 1000
php_value memory_limit 1G
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php81"
php_value upload_max_filesize 2M
php_flag zlib.output_compression Off
</IfModule>
My Files inside the Cpanel
enter image description here
how Can i Solve it , And Thanks
Looks like this question has been asked before, but none of the solutions there worked for me.
I want to create a testing environment for my working Codeigniter (version 3.1.9) website.
I thought I'd do it using a subdomain on my main domain.
I set the subdomain (test.mydoaim.com) through cPanel, and copied all the code files to the relevant directory.
Now, when I go to test.mydomain.com, or to test.mydomain.com/controller_name, it all works well, but when I try any inner links (such as test.mydomain.com/controller_name/anything), I get nothing on Firefox, or this error message on Chrome:
This page isn’t working
www.test.mydomain.com is currently unable to handle this request.
When I change this line on the subdomain htaccess file:
RewriteRule ^(.*)$ index.php/$1 [L]
To this line:
RewriteRule ^(.*)$ /test/index.php/$1 [L]
The error on the same inner pages changes to:
500 Internal Server Error An internal server error has occured.
And that error also appears on test.mydomain.com/controller_name, which was accessible before I changed the htacces file.
So, since the error messages has changed following the alteration, I'm guessing this issue is indeed htaccess related, but I just don't know what should the correct syntax be.
This is the full htacces file:
RewriteOptions inherit
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test/index.php/$1 [L]
# for non www urls, add www and force https:
RewriteCond %{HTTP_HOST}(.*) !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R,L]
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_flag display_errors Off
php_value max_execution_time 120
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 128M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
php_value upload_max_filesize 32M
php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
php_flag display_errors Off
php_value max_execution_time 120
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 128M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
php_value upload_max_filesize 32M
php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^(.*)$ "https\:\/\/mydomain\.com\/$1" [R=301,L]
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php70” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-alt-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
This is my config/routes.php files, in case it is also related:
$route['default_controller'] = 'website';
$route['404_override'] = 'student/four_o_four';
$route['translate_uri_dashes'] = FALSE;
$route['demo'] = 'student/demo';
I'm trying to limit/eliminate duplication.
According to my (limited) understanding of some LAMP hosting providers (especially on shared servers) there are some PHP-ini directives that are ignored when set inside the PHP-script, but is accepted when set in the .htaccess; the process-flow should be quite simple:
detect any mod_php* -and set an environment variable if found
check this environment variable and set all php_value directives ONCE
redirect all requests to PHP for handling requests according to config
The objective is to withhold all content unless PHP is available to handle the request according to config -- per user/bot/api/etc. ..and by this obviously not serve any PHP-code as text O_o
I have no idea why this has to be any more complicated, but I refuse to accept that I have to duplicate a (long) list of php_value directives 4 times -- just because the Apache-conf is too (expletive deleted) to handle the simplest logical conditions .. (face-desk) .. or maybe i just don't know enough about Apache-conf, please help; the code below throws a 400 error, and I can't get it to work unless I duplicate each block for every php-version -and each hosting provider's own mod_php*suffix -for PHP-version-hot-switching.
Here's what [bl/thr]ows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
<IfModule mod_php_null.c>
SetEnv MODPHP 1
</IfModule>
<IfModule mod_php5.c>
SetEnv MODPHP 1
</IfModule>
<IfModule mod_php7.c>
SetEnv MODPHP 1
</IfModule>
<If "%{ENV:MODPHP} =1">
php_value expose_php Off
php_value short_open_tag On
php_value display_errors On
php_value max_execution_time 60
php_value default_charset UTF-8
# list shortened for brevity
RewriteCond %{DOCUMENT_ROOT}/.auto.php -f
RewriteRule ^(.*)$ .auto.php [L]
</If>
</IfModule>
The code below works, however; note that:
<IfModule mod_authz_core.c> is used to verify Apache2.4 -for <If>
RewriteRule is used to define the variable
REDIRECT_ is (conditionally) prefixed to the variable name
RewriteCond %{ENV:MODPHP} ^1$ is used to test if the variable is 1.
<IfModule mod_rewrite.c>
<IfModule mod_authz_core.c>
RewriteEngine On
RewriteBase /
<IfModule mod_php_null.c>
RewriteRule .* - [E=MODPHP:1]
</IfModule>
<IfModule mod_php5.c>
RewriteRule .* - [E=MODPHP:1]
</IfModule>
<IfModule mod_php7.c>
RewriteRule .* - [E=MODPHP:1]
</IfModule>
<If "%{ENV:REDIRECT_MODPHP} =1">
php_value expose_php Off
php_value short_open_tag On
php_value display_errors On
php_value max_execution_time 60
php_value default_charset UTF-8
</If>
RewriteCond %{ENV:MODPHP} ^1$
RewriteCond %{DOCUMENT_ROOT}/.auto.php -f
RewriteRule ^(.*)$ .auto.php [L]
</IfModule>
</IfModule>
I just changed the URL values on core_config_data (since its someone else's repo) to my own URL
but after a while the page located on my VM no longer loads.
According to firebug console:
"NetworkError: 500 Internal Server Error
Even admin pages cannot be accessed. Already made sure folders are rewritable by:
chmod 777 app/etc/
chmod -R 777 media/ var/
also tried moving the .htaccess from Magento home directory to other directories but same error happens.
VHOST
My vhost looks like this:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
.HTACCESS:
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php
############################################
## GoDaddy specific options
# Options -MultiViews
## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini
############################################
## this line is specific for 1and1 hosting
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
############################################
## default index file
DirectoryIndex index.php
<IfModule mod_php5.c>
############################################
## adjust memory limit
# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000
############################################
## disable magic quotes for php request vars
php_flag magic_quotes_gpc off
############################################
## disable automatic session start
## before autoload was initialized
php_flag session.auto_start off
############################################
## enable resulting html compression
#php_flag zlib.output_compression on
###########################################
# disable user agent verification to not break multiple image upload
php_flag suhosin.session.cryptua off
###########################################
# turn off compatibility with PHP4 when dealing with objects
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## make HTTPS env vars available for CGI mode
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
############################################
## enable rewrites
# Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## uncomment next line to enable light API calls processing
# RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
############################################
## rewrite API2 calls to api.php (by now it is REST only)
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## redirect for mobile user agents
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
#RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
AddDefaultCharset Off
#AddDefaultCharset UTF-8
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresDefault "access plus 1 year"
</IfModule>
############################################
## By default allow all access
Order allow,deny
Allow from all
###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
#FileETag none
Kindly advise what should I do? Thanks
uncomment out RewriteBase /magento/ and set it to RewriteBase /
I had same problem. Try changing write permissions to your magento install folder to 755.
You can open index.php file and uncomment these lines to enable developer mode of Magento for debugging.
#Mage::setIsDeveloperMode(true);
#ini_set(‘display_errors’, 1);
I got the same issue and I found out that the error was caused by .htaccess file in Magento root folder. I tried to rename htaccess file and the error is gone.
If it doesn't work, you can try increasing phpmemory limit of your server to ~256MB by adding this line to .htaccess file
<IfModule mod_php5.c>
php_value memory_limit 256M
</IfModule>
After that I replace that .htaccess file with original file from a fresh Magento package and everything is ok till now.
Reference source: http://magentoexplorer.com/how-to-fix-magento-500-internal-server-errors-in-magento-and-magento-2