Custom URL for Magento's basket page - magento

I'd like to implement custom URL for our Magento's basket. Magento out-of-the-box url paht is /checkout/cart but client request /checkout/bag.
I tried to somehow
* URL rewrite management in backend - it works, but I need to update all occurences in code to new url, because $this->getUrl('checkout/cart') doesnt translate into checkout/bag
* also I tried to follow some advices from http://alanstorm.com/magento_dispatch_rewrites_intro but basicaly it doesnt help me too.
* also I tried example from this post http://phprelated.myworks.ro/two-add-to-cart-buttons-with-different-redirect-actions-at-once-in-magnto/
So, is there any way how can I rewrite translation from path 'checkout/cart' into checkout/bag without updating all ocurrences in our templates and classes $this->getUrl('checkout/cart')
Any solution depending on web server architecture are not the ultimate solution.

I found solution
1) I rewrited model core/url to have desired output
EDIT 1 - sample implementation https://gist.github.com/jaromirmuller/132cdd9378e5b1018170
2) Added url rewrite into config.xml which rewrites url path from /checkout/bag to /checkout/cart
<global>
<rewrite>
<mynamespace_mymodule_checkout_cart>
<from><![CDATA[#^/checkout/bag#]]></from>
<to>/checkout/cart</to>
</mynamespace_mymodule_checkout_cart>
</rewrite>
</global>
3) Added url rewrite into Catalog > URL rewrite management which handles if anyone comes to /checkout/cart then he's redirected to /checkout/bag paht which is correct.
These 3 points makes site consisten and working without any issues. That's the easises way without rewriting tons of templates and classes.

The way Url Rewrites work means that you have some url test.com/some on the page and when you click on it, you'll get test.com/some2 instead. So Rewrites do not change the actual anchor link - they change the destination of that link to the new recipient.
There is no easy solution which will change all of the anchor links to the new ones (aside from parsing and replacing links on each page - which is not preferable).
So if you want to leave anchor links as they are and get the new Url after user clicks on the link, you should go with Url Rewrites. Though if you want to change the actual links on the page, you need to search for all occurrences and change them manually.
Mage::getUrl() is not a fabric which operates with aliases (like Mage::getModel()) - you'll get from it what you have inserted, and the only way to change the outcome Url is to change income parameters.

You can do it using apache url rewrites. Something like
RewriteRule ^/checkout/cart(.*)$ /checkout/bag$1 [R=301,NC,L]

This answer works for changing the wishlist name by changing the frontend routers in app/etc/local.xml. Maybe it can be adapted for your uses?
Change wishlist url in magento

To manage more url translation You can use this module:
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/18160/

Related

URL rewrites not working and keep changing the URL extension

I cannot get the URL rewrite in Magento to work correctly at all. I'm trying to redirect a category to a CMS page and at first try it works fine. After I refresh, it starts to change the URL extensions to something completely different than what's shown for the category URL. I've tried clearing the cache and reindexing the URL rewrite but that seems to change it again!
And if I do try to change the URL rewrite to this new, random, made up one that's being automatically inputted - it changes it again! I'm so confused here..
Fixing weird URL Rewrites
Sometimes when you make changes to your products, or enable a certain extension, Magento might start to rewrite all your URLs to include a suffix "-1" or some other number. Within the URL Rewrites, Magento differentiates between System URLs and Custom URLs. If the System URLs are broken like this, you should not fix this by adding new Custom URLs.
Instead, open up phpMyAdmin, create a backup of your Magento database, and flush the Magento table core_url_rewrite (so that it becomes totally empty). Immediately afterwards, refresh the Catalog Url Rewrites under Index Management. This will regenerate all System URLs.
You can also try to redirect through the .htaccess.
Redirect 301 /site-URL-to-redirect www.site.com/url-destination
There are two ways to redirect your category page to cms.
Using Magento native URL rewrite managment.
In Magento 1.x go to
admin -> catalog -> url rewrite managment -> add new url
select custom in Create URL Rewrite: drop down and then give your categoy url as request and cms page as target.
Using .htaccess file. Add this line of code into the file .htaccess:
Redirect category-url cms-page-url

Is there any way to replace "&" with "&" in Magento URL

Is there any way to to replace & with & in magento url.
Every time when magento URL is redirecting from one store to another it is adding & between the url. And the url is breaking. for eg:
https://www.indelust.com/designer?d=370
Above URL is the default url which is linked to US storeview based on US geoIP. When I am clicking on the url from Google search results it should redirect me to the same page with respective storeview. Now below url is the one when I clicked on google search result.
https://indelust.com/in/designer?___store=in_storeview&d=370
And the above link is breaking.
When I am making a small correction in the above url, by changing & to &. Then it is working fine for me.
I gone through some tutorials and below I found the relevant one, but I did not get the answer to resolve based on magento url pattern.
https://magento.stackexchange.com/questions/38513/amp-instead-of-in-language-switch-url
Can anybody help me?
You should find out why the issue appears, but if you just want to replace the url you should add this to your .htaccess file:
RewriteEngine On
RewriteRule ^(.*)&(.*)$ /$1&$2 [L,R=301]
An htaccess file is a set of rules a server runs through for each page request. Adding all of your old URLs to this file means that for every page visit your server has to do a lot more work - it has to compare the URL the user is visiting to all of the old URLs you have added to the file. Magento isn't renowned for its blistering speed, so slowing down every request seems like something worth avoiding
execute the following query in mysql (via phpmyadmin or command line) to see what the current values are:
select * from core_config_data where path like '%base%url%';
and then update accordingly
update core_config_data set value = 'http://myhostname/js/' where path = 'web/unsecure/base_js_url';

joomla rename component url using htaccess

I'm building an eshop using Joomla 2.5 and a commercial component for a guy who wants to have multiple vendros and I'm stuck on how to change the component's url.
What I want to change is the url that is displayed when the users passes from a link with his mouse.
For instance, the component has a SEF function which rewrites urls and makes them like that:
http://www.site.com/componentname/products/productname-productid-productcategoryid-vendorid.html
http://www.site.com/componentname/catalog/categoryname-categoryid-numberofpage.html
and what I want is to make it:
http://www.site.com/shop/products/productname-productid-productcategoryid-vendorid.html
http://www.site.com/shop/catalog/categoryname-categoryid-numberofpage.html
So when a user passes over a link it will show him the new url. Is this possible with .htaccess and rewrite rules or this can only be done through the component only? I'm asking this as the component is encoded with ioncube so I can't do it myself.
Thanks in advance!
While you can use .htaccess to rewrite any URL it won't work with Joomla! as the SEF URL is created by JRoute which uses a combination of the core route function and the route.php for the component.
The URL segments are used to find the right component to handle the request, so to change the way the URL is built you would have to modify the route.php of the component (and obviously other parts as well).
For more information on how SEF support works, read this on docs.joomla.org

How to change Magento admin URL to domainname.com/index.php/customname1/customname2

There are so many articles talking about how to change Magento Admin Url to a single and different name like domainname.com/index.php/myadmin but none of them tells me how to change the admin url to a multi-path url like domainname.com/index.php/name1/name2/name3
I tried to change the name in local.xml but it works only for single name. Please help? Thank you in advanced!
I'm not sure that it is possible. The basic method is to change the front name "admin" to "whatever" in the local.xml to get access to the backend. Based on it, you can probably make some changes of the behavior of the router thanks to a rewrite.
A possible way which works for modules is to do a rewrite but I didn't test on backend module (adminhtml) and it could be not to work for other backend modules or make some trouble. Here is a sample to do in the local.xml, make some tests. Regex in the "from" Tag may work too:
<config>
...
<rewrite>
<mage_adminhtml>
<from><![CDATA[#^/whatevermodule/whatevercontroller/whateveraction#]]></from>
<!--
- whatevermodule matches the router frontname below
- whatevercontroller matches the path to your controller Considering the router below,
"/whatevermodule/whatevercontroller/" will be "translated" to
"/Mage/Adminhtml/controllers/Catalog/ProductController.php" (?)
-->
<to>/admin/catalog_product/index</to>
</mage_adminhtml>

Use relative urls in Joomla menus

I have joomla site which is located in mydomain.com/somefolder/otherfolder/TheSite. I have created a rewrite rule to invisibly redirect all requests beginning with mydomain.com/TheSite to this url. It works fine.
My problem is that the urls that my menuitems point to are the old mydomain/somefolder/otherfolder/TheSite/stuff. If they were relative urls, it would work.
My question: How can I force joomla to use relative urls for the menuitems, or use the urls I explicitly specify?
Thanks in advance
Probably the easiest way to make Joomla produce only relative URLs is to edit the core method "_" of the JRoute class:
JRoute::_()
This is called by Joomla application and extensions to generate consistent URLs.
It is found in:
libraries/joomla/methods.php
Making Joomla spit out relative URLs probably isn't the best way to do it. Making the absolute URLs point correctly would.

Resources