I have problem in rewriting the admin Customer controller class. It is working fine in my local system but in my server it is not. The following is the code used to rewrite the admin customer controller class:
<rewrite>
<Ritwik_Wishlistenhanced_Customer_exportCsvwishlist>
<from><![CDATA[#^/admin/customer/exportCsvwishlist#]]></from>
<to>/wishlistenhanced/customer/exportCsvwishlist</to>
</Ritwik_Wishlistenhanced_Customer_exportCsvwishlist>
</rewrite>
Usually it's because production server is running Linux/UNIX which has case-sensitive file system and that influences controllers lookup. So you probably need to change exportCsvwishlist to exportcsvwishlist in your rewrite and case of yourcontroller.php file
Related
I want to add re-write rules to my Azure app service, but if I even try create a web.config with a simple rewrite as shown below, the site returns an HTTP 500.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="test" />
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
What I did is create the web.config from scratch and FTP it into the wwwroot folder for the app service which is where I Ftp'd the rest of my web site files.
I have seen an old conversation about web.config files in Azure, but I'm not even sure if this is in regards to Azure app service - and things change so quickly in Azure that I thought I should ask separately anyways.
I have also seen this link about using web.config transforms. Maybe this is required?
This other link seems to indicate that updating web.config is possible, but their example results in an HTTP 500 for me as well.
I've looked through configuration options in the Azure portal for my app service and nothing seems to jump out at me.
>>”This other link seems to indicate that updating web.config is possible”
Yes, we could update the configuration of Web App by updating Web.config file directly. You could upload a new version of configuration file to wwwroot folder by FTP/WebDeply or any other ways provided by Kudu. Another easy way to edit files in wwwroot folder is using the App Service Editor, you could use it to edit the configuration file.
I can’t reproduce your problem on my side. Following are what I done.
Create a Web App using a Web App Plan with “Shared” SKU.
Create 2 file, a index.html file and a Web.config file. The content in Web.config is same as yours.
Upload these files to wwwroot folder of my web app using FTP.
Open a web browser and input a URL like this “http: // xxx.azurewebsites.net/test”. The web server will return the content of index.html. It proves that the rewrite is working fine.
>>”but their example results in an HTTP 500 for me as well.”
Firstly, please mark sure whether the rewrite is working fine or not. I suggest you view the index.html page directly and check whether the error code(500) comes from index.html page.
Sometimes we provide the wrong syntax for rewrite rule, it will return 500 (URL Rewrite Module Error). Have you enabled Detailed Error Logging and Web Server Logging for your web app. If yes, you could view the detail error message to get more useful information. For how to enable and view diagnostics logging, link below is for your reference.
Enable diagnostics logging for web apps in Azure App Service
If we enable https in our site at admin apnel then home page and checkout pages will run under https and other page will run under http only. So in which page we make this settings? I know by default magento provides this, But I need to know in which file this configuration will de defined?
The configuration for certain pages to be secure is done in the config.xml file of each module. Let's take as example the checkout page. In app/code/core/Mage/Checkout/etc/config.xml there is this:
<frontend>
<secure_url>
<checkout_onepage>/checkout/onepage</checkout_onepage>
<checkout_multishipping>/checkout/multishipping</checkout_multishipping>
</secure_url>
....
</frontend>
This tells Magento that the pages /checkout/onepage and /checkout/multishipping should be secure if HTTPS is enabled.
The decision if an url is secure or not is made by this line:
$this->_checkShouldBeSecure($request, '/'.$module.'/'.$controller.'/'.$action);
in Mage_Core_Controller_Varien_Router_Standard::match() method
We have purchased the Embedded ERP Extension for Magento. We have customized it, and have rewritten few controllers also. here is a snippet from my config.xml file
<admin>
<routers>
<mdn_extended>
<!-- should be set to "admin" when overloading admin stuff (?) -->
<use>admin</use>
<args>
<module>MDN_Extended</module>
<!-- This is used when "catching" the rewrite above -->
<frontName>mdn_extended</frontName>
</args>
</mdn_extended>
</routers>
</admin>
<global>
<rewrite>
<mdn_extended_advancedstock_warehouse>
<from><![CDATA[#^/AdvancedStock/Warehouse/#]]>
</from>
<to>/mdn_extended/AdvancedStock_Warehouse/</to> <!-- THIS IS AJAX CASE -->
</mdn_extended_advancedstock_warehouse>
<mdn_extended_advancedstock_stockmovement>
<from><![CDATA[#^/AdvancedStock/StockMovement/#]]></from>
<to>/mdn_extended/AdvancedStock_StockMovement/</to> <!-- this is page REFRESH CASE -->
</mdn_extended_advancedstock_stockmovement>
</rewrite>
</global>
Now we have an interesting issue here.
in first rewrite case if you make any action like sorting / filtering on the grid. It sends and ajax call. In normal case, if session is gone the server returned a denied json like following format
{"ajaxExpired":1,"ajaxRedirect":"http:\/\/upgrade.magento.com\/index.php\/admin\/index\/login\/key\/90d3e0a32ecc2cb8e4183ecde51a0d54\/"}
But in first case, the denied json comes in following format, the url is changed
{"ajaxExpired":1,"ajaxRedirect":"http:\/\/upgrade.magento.com\/index.php\/AdvancedStock\/index\/login\/key\/2e96b02d545ee3fddaea963ae6ec5d35\/"}
Due to this user goes to 404 page.
Now consider the second rewrite Rule.
In this case, if session is timed out and if you make any actions on grid it refreshes the page but instead of going to login page it reports fatal error (trying to get username)
After hours of Debugging we found that its the issue of layout handles.
In normal case, if route name is module/controller/action then magento loads
layout handle
<module_controller_action> from xml file also loads <admin_index_login>
due to that finally <admin_index_login> is rendered.
In case of second rewrite magento is not loading <admin_index_login> handle therefore it shows the fatal error.
I'd appreciate any hint or help in this direction. If you guys need any other info I'll be happy to provide you. Thank you so much!
Kindof a late answer but we've also had this problem on another module overriding the sales_order action. We basically solved it by overriding the construct of our custom controllers like this:
protected function _construct() {
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
$this->_forward('adminhtml/index/login');
return;
} else {
parent::_construct();
}
}
While this solves the issue at hand, the core problem seems to be with the class Mage_Adminhtml_Controller_Action where the denied action calls $this->_redirect('*/index/login'); which basically redirects, in your case, to mdn_extended/index/login. This may actually lead to some security risks, so I suggest you always overrite the controller like this, or change the core class to redirect to adminhtml/index/login.
I'm sure this is a simple issue, but I have noticed that when I host (shared host on GoDaddy) a website the URL repeats the Application name.
Example, I have http://makedifferences.org, if I go to this its fine, but if I click a link it takes me to http://makedifferences.org/makedifferences/...
It's not just this one site, it's all my sites on GoDaddy and I think it may be the same on my sites hosted elsewhere, but I can't check them rite now.
I'm not using web deploy to deploy it, as my first thought was it had to do IIS. My guess is that it must be a setting in Publish Settings, but I played around with them and couldn't seem to get it to go away.
Any advice would be appreciated.
Thanks,
Garrett
Update
This is apparently not a mvc thing as I check on a site I have hosted at dotnet-host.com and it doesn't have this problem. So I guess it is something with my settings at Godaddy.
I have deleted the folder and setup a virtual folder and this did not fix the problem.
I have multiple site hosting through them and my domain name A record is my dedicated IP for all the sites, then in host's domain management I point the domain name to the folder the site is in.
I think this is the correct way to do this but am not sure.
To restate my problem now that I know a bit more about it, if I type in http://makedifferences.org/Charities/Details/3 the page loads and everything is perfect. But if I click a link on the home page to go there the url is http://makedifferences.org/makedifferences/Charities/Details/3
Thanks why I thought it was a setting in Visual Studio.
There are two things that cause this behavior.
Your Application is installed in a folder instead of root directory for the shared hosting.
Your DNS settings point the domain name to this folder.
I suppose you are hosting multi-websites in shared hosting.
To get rid of this problem, you need to go in the IIS settings and set these folders as virtual directories.....Or create one for each website....And then install your application in that folder.
UPDATE
This is actually not an issue related to GoDaddy shared hosting at all but an issue with hosting an ASP.NET MVC site in a virtual directory. When you use the shared hosting provided by GoDaddy you get a root folder and limitless subfolders, each of which can be its own domain, by way of virtual directory. Unfortunately, MVC’s routing engine produces URLs that will include the virtual directory name appended to the domain name.
For example, let’s say you have a domain named http://www.example.com and your folder/virtual directory name is /File. If you take the MVC template project without making any modifications and upload it to your folder and then go to your url everything will look fine. You will notice the ‘Home’ and ‘About’ tabs at the top right of the page. When you click on the ‘About’ tab, since it is routed to the Home controller’s About action, you would rightly expect the URL to be www.example.com/Home/About. What you will see, though, is that the URL generated by the ActionLink method includes the name of the virtual directory. Therefore, the URL will be www.example.com/File/Home/About.
To get rid of this problem, add the following code to your Web.config’s system.webServer element
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
Solution seeked from HERE
Best of luck :-)
To work in all cases I used rewrite rule:
<rewrite>
<rules>
<rule name="Remove Virtual Directory">
<match url=".*" />
<action type="Rewrite" url="{R:0}" />
</rule>
</rules>
</rewrite>
And the function bellow:
protected void Application_BeginRequest()
{
#region Godaddy shared host fix - Detect VDIR in url and remove
//verified that HTTP_X_ORIGINAL_URL keeps the original url (withoud domain) before url rewrite module,
//that way can check if the virtual directory name is at start, and remove it.
if (Request.ServerVariables.AllKeys.Contains("HTTP_X_ORIGINAL_URL"))
{
var origUrl = Request.ServerVariables["HTTP_X_ORIGINAL_URL"];
var matchVdir = "/" + Myproj.Core.Constants.Environment.HostingVirtualDirectoryName + "/";
if (origUrl.StartsWith(matchVdir))
{
var urlFix = Request.Url.GetLeftPart(UriPartial.Authority) + "/" + origUrl.Remove(0, matchVdir.Length);
Response.RedirectPermanent(urlFix);
}
}
#endregion
}
I have customized customer module to meet my requirement. I am able to rewrite block classes of customer module. I am trying to add one custom block class in this module which is not exists in existing customer module but I don't know how to accomplish this.
my code looks like in config.xml
<blocks>
<customer>
<rewrite>
<widget_name>Mynamespace_Customer_Block_Widget_Name</widget_name>
<form_register>Mynamespace_Customer_Block_Form_Register</form_register>
<form_edit>Mynamespace_Customer_Block_Form_Edit</form_edit>
</rewrite>
</customer>
</blocks>
I created a new block class under the Form directory of customer module called 'Test.php'
And customer layout file looks like
<reference name="my.account.wrapper">
<block type="customer/form_test" name="customer_test" template="customer/form/test.phtml"/>
</reference>
But it is not executing the block class file.
Is there anything should be added in config.xml file of this module?
Please help how this block can be integrated with existing module.
Thanks.
You shouldn't really be adding blocks to the customer module, you should be adding them to your own module. If you want to keep on w/ the customer module, check to make sure that your block is named as Mage_Customer_Block_Form_Test and extends Mage_Core_Block_Template. Otherwise, create the class as Mynamespace_Customer_Block_Form_Test and keep it in your module directory. Then, add a block definition for your class in config.xml:
<blocks>
<mynamespace_customer>
<class>Mynamespace_Customer_Block</class>
</mynamespace_customer>
</blocks>
Then you should be able to load the block as mynamespace_customer/form_test.
It may be easier to debug your problem if you use a module name other than customer. Generally speaking, that is a bad idea and will likely cause bugs in the system.
Hope that helps!
Thanks,
Joe
You may already be aware of this but think about checking LayoutViewer to see what the layout thinks it is using.
Although I'm sure your example config.xml is just an example please make sure that you've remembered to create a rewrite for form_test and that there is a valid blocks section for your own module.
BTW, LayoutViewer could really do with being packaged properly for Magento Connect. The linked file lacks the necessary config to enable the module and it would be much more useful if accessible from PEAR.