Magento 2 404 error admin panel - http-status-code-404

Recently I installed Magento ver 2.0
After successfull installation, I tried to login to admin panel but it say 404 not found.
I am really not getting what is causing such issue. Moreover from the URL it can seen that I am logged into admin oanel but the dashboards is not visible.
URL:
Can anyone shed some light on this ?

I had the same issue. I had to enable the mod_rewrite module and set the AllowOverride to all for /var/www/html directory in the apache configuration file.

Maybe a known issue? Some info regarding a work around currently as well.
https://github.com/magento/magento2/issues/254
According to that, this may fix it:
Quick fix:
in app/code/Mage/Install/Model/Installer/Db.php:64
paste following
if($extName == 0) {
continue;
}
after
foreach ($extensions as $extName) {

The problem is in getting of REQUEST_URI environment variable value and checking it withSCRIPT_FILENAME and SCRIPT_NAME environment variables values.
So a cause of the problem is in adding of /index.php/ prefix to the request path and the Magento url generation has this value hardcoded for admin.
Override method called _updatePathUseRewrites in /app/code/core/Mage/Core/Mode/store.php file :
Replace this Function:
protected function _updatePathUseRewrites($url)
{
if ($this->isAdmin() || !$this->getConfig(self::XML_PATH_USE_REWRITES) || !Mage::isInstalled()) {
$url .= basename($_SERVER['SCRIPT_FILENAME']).'/'; }
return $url;
}
with
protected function _updatePathUseRewrites($url)
{
if ($this->isAdmin() || !$this->getConfig(self::XML_PATH_USE_REWRITES) || !Mage::isInstalled()) {
$url .= '/'; }
return $url;
}
This will definitely solve your Problem

Related

I got a 500 error when I use guzzle but with curl I dont get one

I have an Openhab system on a PI and a REST API and I want to display information on a TV-Screen.
I have tried to do it with a curl and it worked. So now I want to do the same with Guzzle.
First I only installed composer and guzzle in the Project directory on my PC, Then I also installed them on the PI. Neither approach worked as I got a 500 error on both attempts.
function getCurrentTemp() {
echo "test1";
$client = new GuzzleHttp\Client([
'base_uri'=>'http://fernseher/'
]);
echo "test2";
$return = $client->request('GET','http://openhab.clubdrei.com/rest/items/ThermostateTemp/state', ['auth' => ['User','Password']]);
echo $return;
}
I think the creating Client break up the script
I need your help,
Thank you
500 basically means that there is a server error. Please attach the cURL command that is successful (as you mentioned in the question's title).
I also modified your code a bit, to be sure that you are are working with the body content of the response (->getBody()->getContents() part):
function getCurrentTemp()
{
// You don't need 'base_uri' here, because you use absolute URL below
$client = new GuzzleHttp\Client();
$response = $client->request(
'GET',
'http://openhab.clubdrei.com/rest/items/ThermostateTemp/state',
['auth' => ['User','Password']]
);
return $response->getBody()->getContents();
}

How to Disable Direct file Download via .htaccess

I want to disable direct file download to my .zip files.
If my website is the referrer then only download the file.
I am using Apache server
You can try this one which will help you but I will suggest you to research more on this.However you can put the below code for the work.
Also make changes to the below code for the changes.
<?php
// This is to check if the request is coming from a specific domain domain.com
$ref = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref);
if($refData['host'] !== 'domain.com') {
// Output string and stop execution
die("Hotlinking not permitted");
}
echo "Executing code here";
?>
You need to change your domain above eg. clubapk.com instead of domain.com

CakePHP change view for action in plugin

I'm developing a plugin that has an action which decide the view to render according to data properties:
example:
class ProfilesController extends MyPluginAppController {
public function myaction($id){
//..omitting checks..
$profile = $this->Profile->read(null,$id);
//Stuff
if($this->hasDedicatedViewFor($profile)){
$this->render('profiles'.DS.$this->getDedicatedViewFor($profile));
}
//Else render default action view
}
}
While this controller was inside the APP everything was working right,
after moving into Plugin, cake says:
Error: Confirm you have created the file:
.../app/View/Plugin/MyPlugin/Profiles/myaction_secondary.ctp
While I'd expect to load it from:
.../plugins/MyPlugin/View/Profiles/myaction_secondary.ctp
While I'd expect to load it from:
.../plugins/MyPlugin/View/Profiles/myaction_secondary.ctp
It is attempting to load the default plugin path
If you trace through the code for finding template files it is checking multiple paths for plugin view files:
$paths = $this->_paths($plugin);
$exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . $name . $ext)) {
return $path . $name . $ext;
}
}
}
The path in the error message is the last place CakePHP looks for a plugin view path, but it should also be checking the plugins directory. Debug the above code to see where CakePHP is looking for files if in doubt.
The path being wrong in the error message probably indicates using an out of date version of CakePHP; it's always, always a good idea to maintain your applications running the most recent maintenance release for the major version you are using. From the info provided that's 2.7.3 at the time of this answer.

Grails url mapping 404 not redirecting

Is there something else to configure for url mapping to get it working ?
When I type a wrong url in the browser the Chrome console show the error
GET http://localhost:8081/aaa 404 (Not Found)
EDIT:
and in the Grails console I see :
INFO myApp.ProjectController - Entering Action /project/index
But no redirection is doing to the error.gsp view. I tried to change with : "404"(view:'/') with no success.
Notice I use Angularjs in that project but only in one page for the moment.
Thanks for your help
UrlMappings.groovy
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"404"(view:'/error')
}

Cakephp check if referer is from local url

I'm struggeling a litte with my Cakephp 2.1 application.
I want to render a different layout, if the referer is from an external url. Sadly this is not working :
if($this->referer(null, true))
{
$this->layout = 'lightview';
}
else
{
$this->layout = 'default';
}
Any ideas how I can fix this?
Thanks in advance
You got a logical error here:
$this->referer(null, true) // true as second param: only internal
will only return the lightview layout if
there is a referer (not always the case)
internal referrer
So this is probably not what you want.
You cannot do that this easily. Sometimes there is just no referrer.
And even if there is you might still don't know if this person came from somewhere else and just "hid" the referrer. Or then browsed your site (creating internal referrers from here on).
You would need to store the initial result on first visit in the session to check against later on.
But even so your approach is highly inconsistent and very likely breakable...

Resources