Add referrer code to url - url-rewriting

I need add the url of a wordpress blog a referrer code with this structure:
http://domain/([a-zA-Z]{3}[0-9]{3}/...
The site should work both with and without this code.
If there is I have to use it, store it in session type.
All through plugin so you do not have problems with upgrades or any wordpress plugin.
I also tried to edit the file .htaccess with a custom RewriteRule but nothing.
Ideas? Thanks!
Sorry for bad english!

I think you are trying to reinvent the wheel here, there plugins that gives you affiliate program features so you won't have to worry about url and links.
try some of this plugins: Tag: referral
you can also try this one as it has a good description: Affiliates
With wordpress always check existing plugins when you want to add functionality to your website, there are a lot of plugins that do a lot of things.
Edit: you can create your referal link as domain.com?ref=code and in the website header check for $_GET['ref'] if it exists save the ref in a session variable, if the user gets to register then take the ref value from the session variable. This should work

I opted to install the plugin Rewrite and create rules to manage the referrer.
Thanks anyway!

Related

How to create Directory/Folder when using Magento?

We are running magento on our site www.xsmoke.com. The site is international, so we are using "/country code" - e.g.www.xsmoke.com/de/ etc.
Now we would like to install wordpress in one of the languages only and we want the URL to be "xsmoke.com/de/blog".
But i can't create a folder on that location for the wordpress files because of magento.. Does anyone have an idea for a workaround?
Thanks.
I'm not sure how you've set things up but it would be possible to do this by using the technique involving directories and symlinks for multiple websites (rather than have Magento include the store codes in the url). See the below answer on how to do that;
https://magento.stackexchange.com/questions/13171/multiple-country-specific-stores-on-the-same-domain-show-country-selection-firs#answer-13173
And you'd then just install Wordpress in the /de/blog directory. Otherwise you might be better asking another question tagged with .htaccess and ask for a way to do a rewrite that would handle it in the context of Magento's existing rewrites.

*some* magento links pointing to old domain

I have just moved a magento site from one domain to the new one. Steps so far...
Backup the database and restore the database on the new domain. Change the core_config_base table for secure and unsecure base urls
Upload source files
Update the local.xml with new database information
Cleared cache
Now I can go to the site and everything is showing up fine on the new domain. The main navigation is working as it should. When I click on a product, however, it goes to the old domain. Does anyone know why this might be happening?
Can you verify the links when you hover products are correct or in correct consistently? Is old base URL in all links I mean. Also check htaccess file for any directives containing the old domain. Also check to make sure no custom URL rewrites exist in the Magento admin Catalog → URL Rewrite Management .Once you verify htaccess or custom URL rewrites in Magento admin are not causing it, I can suggest other procedures to fix.
Probably your previous developer didn't follow all Magento standards while coding.
My suggestion is download your code and search for strings that equates to your previous domain.Also check in data base, as use of CMS blocks too might result in previous domain links.
Btw make sure you delete all caches
Rm -rf var/cache/*
Verify base URL and secure URL are correct in all scopes via drop down in Magento system configuration.

Magento "Shop By" URLs use "#%21" instead of a "?"

I'm working with a new Magento installation and using the shop-by links give me
example.com/catalogsearch/result/#%21color=1&q=shirt
instead of
example.com/catalogsearch/result/?color=1&q=shirt
I'm not sure where I should look to begin fixing this.
Thanks!
we had this same problem and found that a plugin was changing the url with str replace
changing the ? for #%21
the plugin changes the url so that it can be identified by the javascript file and updated via ajax.
the plugin in our case was vingento there seemed to be some confilcts with other plugins. After disabling this plugin and code our filter and paging links work again, although not via ajax.
Hope this helps you

Magento: ?___SID=U appearing in some urls

Can someone please explain why ?___SID=U is appearing in some Magento URLs on my site and not others?
I think it has something to do with sessions but I am not entirely clear. Also, what makes it more confusing is the fact that it's only appearing in some URLs and not others.
I don't need to know how to remove it as I am aware of the setting in the admin area. I would really like an explanation of what it is, what its purpose is and why it would show on some pages and not others. id rather understand what's going on fully than blindly follow some advice as to how to remove it.
I addition to Brendan's answer, the ___SID=U is used in the cache as a placeholder for the session ID. It is replaced by Mage_Core_Model_Url::sessionUrlVar() which in turn calls Mage_Core_Model_Url::sessionVarCallback(). These methods are called from Mage_Core_Block_Abstract::_afterCacheUrl(), which means that any URL found in block output will contain the correct session ID (if needed).
So to get rid of the parameter in your own code the "right way" use this:
$url = Mage::getUrl('some/magento/route'); // might append ___SID parameter
$url = Mage::getModel('core/url')->sessionUrlVar($url); // process ___SID
If the string still displays in the rendered page that is a bug. Are you using some custom caching module, or generating URL's using a non-standard way?
The SID is a "session ID". Magento uses this to track a user's activity within the same Magento installation. Normally, Magento powers one website and one store from one installation (database).
Magento could power multiple websites with multiple stores from one installation though. The SID allows users to stay logged in while navigating across these websites/stores.
I think if you have the function enabled, the SID is sent when accessing catalog URLs so Magento can update the session with the user's location/state for the current website/store.
If you're not running a multi-website or multi-store environment, it's safe to disable the SID on the frontend.
Just something i come across today and though i make a comment, maybe it will help someone.
I found that Magento will format/create an incorrect product url (inc. Session Id) if there were some errors during processing the page. This is not consistent though.
It worth having a look at your server logs for PHP errors.
This is a general Magento 2 bug which is already reported to magento.
Temporary fix is
Go to Document Root,
Find .htaccess and add
RewriteCond %{HTTP_HOST} ^abc.com
RewriteRule ^(.*) www.abc.com/$1 [L,R=301]
below.
This should solve the issue. For me this work in M2.1
All the best.
Reference : https://github.com/magento/magento2/issues/5517
I hunted for hours to find this and the precise answer was a combination of the other answers listed here. First, I cranked up my PHP error reporting and error logging (thanks Gergely Varga). I saw this:
PHP Fatal error: Call to undefined function mb_strrpos() in /var/www/html/app/code/local/ManaPro/FilterAjax/Model/Observer.php on line 59
So, one of our installed extensions requires the php-mbstring package, which my server didn't have installed. As soon as I installed that, the SID=U URLs all disappeared. (In future I'll be running Magento's pre-install checks before copying an existing install over to a new server!)
Thanks to Vinai too for the background of what this tag is for.
Go to Store > Configuration > General > Web > Session Validation Settings > Use SID on Storefrontand and set the value to No.
Clear the Magento cache

Mapping Old URLs to new joomla 2.5 website SEF urls?

I have a weird situation. A client of mine has a website having this kind of URL:
OLD URL: website.com/products/the+product_1.php
Now the new website that we developed has joomla 2.5 and has all content in there... So we have enabled Joomla SEF there. Now the issue is how to map the OLD urls to new Urls.
And the new Joomla 2.5 URL Looks like this:
New URL: website.com/products/digi/category/the_product_1
Now the issue is the search engines have indexed the OLD URLs and client does not want to loose the Page Ranking as you know how it matters.... They have about 18k URLs.
How best I can map the Old URLs to new URLs?
Please help?
Hm, why didn´t you use the Joomla build in redirection manager?
http://docs.joomla.org/Help17:Components_Redirect_Manager
Sure it takes some time to build the links into it, but from my point of view this would be the best way. Then there is no need to develop something and everything can be managed in joomla.
You can also write a script which add links to the SQL DB if needed for this component.
The easiest way would be to create a system plugin that looks for the old product URL pattern and fires a redirect to the new URL. You should also look at this list of new and renamed events as some of them have changed since the plugin documentation was written.

Resources