domain mapping in CakePHP - php

I'm trying to do domain mapping on my site in the fastest possible way so I've searched for PHP plugins that I can possibly use. However, all results are Wordpress-related. I'm using Cakephp 2.4. Is there an available plugin for this that is not WP? If not, how can I make use of the WP plugin to make it work in Cakephp?
[EDIT]
For example, if I have a public page on someonessite.com/myname and I want mysite.com/me to redirect or map the former site then I'll have to set something on someonessite.com so that mysite.com/me will display someonessite.com/myname via domain mapping.
[NEW EDIT]
So, I want to map mysite.com/me (my own site) to the IP address of someonessite.com/myname (someone else's site that I have account at and where I want to add this php code to)
eg.
I will save my own/customized site (mysite.com/me) at someonessite.com and let someonessite.com map my own site to their IP address to display someonessite.com/myname

You are not very clear on what you want, but at a guess it looks like you need this
You can use that plugin to set up different configs based on what domain is loaded. I use it for that use case also.

On mysite.com/me
use
<?php
/* Redirect browser */
header("Location: http://someonessite.com/myname");
exit;/* Make sure that code below does not get executed when we redirect. */
?>

Related

Redirect my website joomla

I want to redirect my website in differents languages when detect the country by (GeoIP), actually i have these urls and works well clicking on the flag images.
www.myweb.com/en www.myweb.com/es www.myweb.com/pt
But i dont know how to do it in joomla using the geoip.
I tried with .htacess and the answer of this question
how to redirect domain according to country IP address
and i have the error 500
SOLUTION:
Joomla provides a browser settings in system language plugin, just setting the joomla with this works perfectly!!
This extension does the job: http://extensions.joomla.org/extensions/style-a-design/templating/11173 Note that it's commercial. Your alternative would be download the GeoIP database (it's available for free), and then create a small plugin that does the redirection.
If you want, you can take a look at our post here: http://www.itoctopus.com/how-to-block-a-whole-country-on-your-joomla-website on how to block a country. You will only need to slightly modify the code to make it so that it redirects to another page for a certain country.
Try this,
Create a system plugin for Joomla
PHP functions available for checking visitors country use that identify the location.
redirect according to that.
Hope it helps..

run a function on each page

My codeigniter app is multilingual and I want to redirect users to their pages, by checking IP address.
I should check it at the top of all pages (i know i can set a session or cookie, but i want to check it on all pages); before any views or other.
Where should i put my code (function)? on Startup file or Loader? or create an extension or plugin and load it on Startup? if it can be done by an extension or plugin, how can I create it? (i've searched, but didn't find a useful tutorial)
Thanks.
If you're using a main front controller you can put your code in there. But a better way to do it would be to use CodeIgniters built in functionality to extend the core - hooks!
http://codeigniter.com/user_guide/general/hooks.html
Just select the point you want your script to be activated and take it from there.

How to make static Dynamic pages?

In MyBB forums you must have seen that all those threads are stoed as forum.com/Thread-Name-of-the-thread
So now this is static right ?
So now i have a site which has
blog.com/search.php?=SEARCHED+TEXT
So now how do i save this search so that Google can find out this page on my site ?
Indirectly what i mean to say is how i can i make
blog.com/SEARCHED+TEXT.html
"So now this is static right?" No. Just because the URL doesn't end in .php or similar doesn't mean it's static. It's time for you to learn the wonders of mod_rewrite:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
Your first example isn't static at all. It's just using a tool to route the request based on the URL.
All you need to get the same functionality is to investigate URL Routing in PHP and implement it in your application as well.
If you want Google to index this search page you have to tell Google it exists, either through a Sitemap or by putting a link on your site that Google can crawl. Google did fill in forms in the past, but I am not sure if they still do and afaik, they only did on a selected few sites.
To make the search static, you have to render the page once and store it in a file. Whether you do that manually by simply calling up the file in your browser and then saving it or by means of a Caching System is up to you.

Codeigniter, domain to a certain area of the site

I'm not a very experienced programmer, and am using CodeIgniter for second time.
Suppose I have www.domain1.com. So I will have, say 3 controllers /area1, /area2, /area3. Users can access them as www.domain1.com/area1 etc. if I set the base URL as www.domain1.com. But my problem is, the client wants a certain area of the web, say area2, working as a microsite, in its own domain, so he wants to access area2 with www.domain2.com.
I don't know how to get this working with CodeIgniter. Suppose he registers www.domain2.com and set it pointing to the same DNS, server etc. How can I get CodeIgnitor to execute the controller area2 when the URL www.domain2.com is accessed?
Maybe changing $config['base-url']? Routing? .htaccess? Please, if you have solved this, examples of code involved would be greatly appreciated.
Edit: I will put example of the site I want to get.
I have one normal installation of CodeIgniter (external host, I can't access httpd.conf) It is on one machine, and the root of the site should be accessed by www.domain1.com
All domain are outside registered to. So I have the home controller, which shows me the main page view. And suppose the site have 3 areas /area1, /area2 /area3, with their correspondent controllers, showing these areas views.
My client want to emphasize one of the areas, the one that controller /area2 shows, and he want use a different domain for that area, www.domain2.com
What can I do so that when the user browse to www.domain2.com, CI redirects them to www.domain1.com/area2? Could I, for example, modify $config['base_url'] according the received URL, or is that impossible? Do I need to modify the .htaccess file?
After a lot of searching, I found a solution that seems to work, very easy to be honest:
Modify routes.php:
if ($_SERVER['HTTP_HOST']=="www.domain2.com") {
$route['default_controller'] = "area2";
}
No need for mod rewrite.
Here's a helpful link....
http://www.askaboutphp.com/88/codeigniter-setting-up-multiple-sites-on-one-install.html
Never actually done this myself, but this seems to be the way to go about it without having two ci installs. Good luck.
you definitely need to go the mod_rewrite way
the first solution that comes to my mind is to use Apache mod_rewrite, but as far as I know that would work only for internal redirects (i.e. resources residing on the same server/domain).
What about using an iframe? You could set up domain2.com home page with a full-page iframe that takes it's content from domain1.com/area2.

Wordpress: using a test theme only for a specific user

I'm testing a new template for a wordpress based site, and I'd like to test it directly on the live version instead of making copies. I thought I could create a test user (wordpress is bridged with vbulletin which handles user auth), serve the usual theme to anyone BUT that specific user, who would get the new testing one.
I don't want to install a plugin, I'm looking for the right place to edit to insert this check:
if logged user == test_user_id
serve 'testtheme'
else
serve 'normaltheme'
The userid can be get from $_COOKIE.
I tried hacking the get_template() function in wp-include/theme.php but apparently that was not enough. Any suggestion?
This is the best way to "test" or develop a theme behind the scenes without needing to alter too much of your Wordpress core or make custom changes...
http://digwp.com/2009/12/develop-themes-behind-the-scenes/
Just logging into my old Wordpress.com blog, I see that I can do all the previewing I want from the themes manager already - click around to any page I like, or bring up the frame's URL to see what query string I'd have to append to a URL to get the same preview, e.g.
?preview=1&template=pub/mytheme&stylesheet=pub/mytheme
Any reason that's not enough?
Perhaps you should add a column to your user table, call it "is_beta" and if it's set to 1 then enable beta features/themes. This way you can easily add or remove people from the beta, and when you're beta is ready to launch, you flush the column for everybody and make the features default.

Categories