How Can I edit magento Rewrite.php to keep get parameters - magento

I have the same issue described here: Magento URL Rewrite Management preserve GET parameters
Which kind of changes should I do to Rewrite.php? Is there any other way to make it work in general without changing rewrite.php?

Build the urls like:
$this->getUrl("*/controller/action", array('param1'=>value, '_current'=>true));
The value '_current'=>true will keep your current params in the new URL

Related

TYPO3 - Ajax Call to extbase plugin loses typoscript

I have a TYPO3 extension to access stored entries in the database (kind of a news-list).
This works well when I directly call the extension.
But then I have to load more entries via ajax and this is when everything fails.
I used this tutorial to build the extension: http://www.sklein-medien.de/en/tutorials/detail/building-an-typo3-extension-with-ajax-call/#c83
In my Typoscript, I have
plugin.tx_myext.persistence.storagePid = 123
plugin.tx_myext.settings.typeNum = 12345678
These settings seem to get lost when I make the ajax-call.
I have to hardcode the settings into the setup.ts of the extension (myext/Configuration/TypoScript/setup.ts).
The problem is, that when I move the extension to another server, I'd have to edit the extension everytime to adjust the settings, instead of being able to set them via Typoscript.
Any ideas what could be wrong?
Apparently, I just called the wrong URL.
Initially, I called «index.php» in the ajax-call.
I had to call the URL of the page the plugin is on (e.g. /en/mypage/mypagewithplugin).
Then, the call was made, but T3 complained about the cHash not being calculated. So I changed the ajax-call from GET to POST and it was working.

Firefox-Addon: Add search engine with varying URL and suggestions

my Firefox addon shall add a search engine, that
provides suggestions
gets its search template URL specified on runtime (i.e.: template URL depends on the preferences of the user)
And I don't see a way to do both at the same time.
I see two options to add a search engine:
addEngineWithDetails
addEngine
addEngineWithDetails() allows me to add a search engine with the template URL. But it does (apparently?) not allow to provide a suggestions URL.
addEngine() allows me to add a search engine that is specified in an XML file. But if have that file saved locally in my addon directory (e.g. chrome://example-engine/content/search.xml), how can I change the template URL on runtime? And using an online XML is an unsafe options since the internet connection could be broken or bad during the addon install.
First fo all, you're right, addEngineWithDetails does not support suggestions.
The way to go would be to use addEngine (and removeEngine).
As for the "dynamic" part of your question: While I didn't test it, the implementation seems to happily accept data: URIs. So you could:
Construct a data URI using whatever methods you like (even constructing a full XML DOM and serializing it).
Call addEngine with the data URI.
When the user changes a pref, remove the old engine, and construct a new one.

Is it possible to redirect a url using spring

I'm working on a project using spring, MVC, and implementing webapp-runner. The project used to have a hierarchy like /test/home/index.jsp but using webapp-runner it changed to /home/index.jsp. So, What I need is to support and redirect the old url's with "/test/home/index.jsp" to "/home/index.jsp" so the page doesn't brake in case an old url is used.
I will be thankful if anyone can give me a hand.
return "redirect:/home/index.jsp";
in your controller that returns viewname, or create a second controller with the required mapping .
I would solve this by having an Apache2 in the web app server redirecting the old traffic to the new URL structure.
Installing it in the server is as simple as running
apt-get install apache2
Whether I'd use rewrite or redirect would depend wether you want to maintain the old URLs or not.
See here for more information: http://httpd.apache.org/docs/2.4/rewrite/remapping.html

Url routing in elgg

I am trying to create a social network application using elgg.Since i am pretty new to elgg i like know whether i can define url routing like in cakePHP
I need the url like this
mydomain.com/username instead of mydomin.com/pg/profile/username
Is there any way that i can avoid /pg/ and /mod/ from the urls??
I am using elgg version 1.7.8.
I am not interested in url rewriting with .htaccess.
Thanks in advance
elgg itself is using .htaccess file to redirect /pg, /action etc. So, I think there is no other way than using .htaccess.
Elgg's page handling is pretty bad but you can register handlers as follows.
for /mypage:
elgg_register_page_handler('mypage', function($pages){
//content here
//the $pages parameter is an array. so /mypage/a/b with return
// array('a','b');
});
Matt Beckett has written a profile URL plugin (https://community.elgg.org/plugins/1091233) that, though for 1.8 and above, is only 35 lines of code and does exactly what you ask. You should be able to adapt this quite easily for 1.7.8.
He has also written a fuller page handler hijack plugin that may help if you have other use cases apart from user profiles - see https://community.elgg.org/plugins/854839
It is also only for 1.8 and above, however, and may take more effort to backport than the first.

Apache internal rewrite module for unique URLs?

I am trying to create a secure download web app with the following scenario. Anybody know how this can be achieved:
1) The user is given a one-time URL
a) This one-time URL is stored in an Oracle DB mapped to the actual URL
2) When the user visits the one-time URL:
a) Apache module connects to the DB to see if the one-time URL exists
b) if it exists, apache does an internal rewrite to the actual URL
c) if not, then 404 or any sort of error (404 or something else) is good enough
2.a and 2.b are the what I am looking answers on. I am not sure how to do this and make sure the rewrites happen internally.
Thanks
This should be possible using the new dbd-type RewriteMap functionality available in the trunk version of Apache. Obviously with this being the current development branch of the server you'll need to be careful about config-breaking changes over time.
RewriteEngine On
RewriteMap urlmapper "dbd:SELECT redirect_url from my_table WHERE some_key = %s"
RewriteRule /one_time/(.+) ${urlmapper:$1|/404.html}
Of course you will need some additional logic for handling cases where no results are returned.
http://httpd.apache.org/docs/trunk/rewrite/rewritemap.html#dbd
AFAIK this is not possible just by apache. What you must want to do is:
Configure apache to redirect that unique links to a server script which will make the "magic" happen
the server script checks if the unique provided url is still valid and acts in accordance:
serves the file and invalidate (delete or mark as served) the unique-url row in database
replies with status 404 or redirects to a 404 page in other cases
The exact details on how to make things happen depends on the scripting engines available to you on the server, and your preferences. It can be done in a variety of engines, from php to cgi to .NET to asp and many others.
Figured this out... You can achieve this using XSEND (https://tn123.org/mod_xsendfile/)... Setup a php script to handle any URI's with file download and denied all access to the actual file directory so the only way to get the file it to force it through XSEND.

Resources