Can I use codeigniter session cookie data for authentication? - wordpress

I have a CodeIgniter install, which I use for most of the site. I have a /blog folder, in which I have a Wordpress install.
Goal: pages inside the /blog will look have the same header as the rest of the site. They'll also have all the features of Wordpress.
For pages inside the /blog folder (running Wordpress), I'm loading the CodeIgniter header view via a file_get_contents() call, since I don't have access to the CI framework from within Wordpress. I prefer not to create another copy of the header view within the Wordpress template, because I'd like to maintain just one file.
Now here's the problem: I can't maintain the user's state in Wordpress, because I don't have access to CodeIgniter's session.
Since the call to the header is done via file_get_contents(), the server doesn't have access to the same session as the client (since it is in effect a call from the server).
Is there a way I can transfer the session cookie data into CodeIgniter via the URL? Something like:
file_get_contents('http://mydomain.com/header.php?data=SESSIONDATA').
Am I even thinking about this the right way? Note that we are obviously on the same domain, just a different folder.

Check out the following links that might be useful:
http://wordpress.org/extend/plugins/wp-code-igniter/
http://jidd.jimisaacs.com/post/wordigniter-wordpress-codeigniter/

Related

Netlify Custom Domains and WordPress admin access

Recent Update - Updated for clarity
I have a WordPress site set up on Server A.
Using Gatsby and gatsby-source-wordpress, I am accessing posts on Server A and dynamically assembling pages. I am then deploying a Gatsby site to Netlify.
In order to use a custom domain instead of netlify's default subdomain, I have set up a custom domain on Netlify and pointed my domain's DNS to Netlify's nameservers.
The problem is when I navigate to mycustomdomain.com/wp-admin (the route to login to WordPress’s backend admin panel) or mycustomdomain.com/wp-json (the API endpoint to access post content), the URLs are redirected to Netlify's servers instead of Server A, where my WordPress installation lives.
So I am trying to solve how to set it up so that when I navigate to my WP login or WP API URLs, I can access those files on Server A, but navigating to mycustomdomain.com goes to my Gatsby/Netlify build.
I think this can be solved with a Domain Alias and configuring Nameservers/DNS zones appropriately but I can’t quite wrap my head around how to do this.
Thanks,
Below is not the right way but maybe it will help you.
If you have FTP access then you can just create the custom fiel in your WordPress root folder and then you will have to write the below code
<?php
include "wp-load.php";
wp_set_auth_cookie($your_user_id); // generally 1 for the main admin user
?>
Run your newly created file like below http://example.com/custom_file.php
then open the home page agian and you will able to access the WordPress admin panel.
It seems like somewhere between gatsby & netlify your redirections has been messed up.
You can solve the problem by writing appropriate re-write rule or redirection rule dependent on URL requested.
Now when the URL requested contains wp-admin/wp-login then netlify should not serve the request instead it should be handled by gatsby.
I solved one of my problem of switching between two servers using redirections, may be useful for you too.
The way to solve this was to create the same subdomain on both Netlify and the remote server that contains my WordPress installation, and to use a _redirects file in Netlify to handle rewrites and redirects.
For example, I'll create wp.mydomain.com as my subdomain.
Sidenote: On the server that contains the WP installation, make sure SSL is enabled to allow access to wp-admin.
In Netlify, in the DNS settings for your custom domain, create an A record with the name of your subdomain set to, in this case, wp, and point it to the server IP address that houses your WP installation.
Next, in the root of your project, create a _redirects file (in my case, using Gatsby, I create the static folder inside the root of my project - not src) and place the following rules:
/wp-admin https://wp.mydomain.com 200
This says that anytime I access www.mydomain.com/wp-admin redirect me to wp.mydomain.com/wp-admin, the subdomain I set up on my WP server. This routes my request to my WP server and not Netlify.
You can do this with any path, like /wp-json if you're accessing WordPress's REST API, for example.
This was a pain to get working. I hope it helps someone out there!

Wordpress - Prevent redirection to main URL

I tried to copy the files of a WordPress website on another domain of mine.
But it keeps redirecting to the old domain name.. I'm not a WordPress expert and it's also not my website - that's why I don't have a GUI and only the files.
How and where can I disable the redirection to the main domain in the files? I can't seem to find it.
Thanks for the efforts.
For example:
WordPress website "test.com" copy paste --> "testtest.com"
"testtest.com" redirects to --> "test.com" when entered in URL
When you transfer a Wordpress install to a new domain, there are 2 values you need to update in your database. One is the homeurl and the other is the siteurl. Typically these changes would be made directly in the database, either by modifying the sql file before importing it on the new server or by accessing the database using PHPMyAdmin or some other form of database management software. However, in the event that you don't have access to the database or do not want to make the change in the database, you can also override the settings in your wp-config.php file using the following options:
define('WP_HOME','https://yourdomain.com');
define('WP_SITEURL','https://yourdomain.com');

Moving a wordpress site without passwords or access

I am looking after a site where I have no access from the previous web designer. I have gained access to the domain name, and now want to move the site to my server.
So far I have been able to copy the site using some software I found, and I have the files locally on my computer.
How do I keep the existing site but gain access so that I can update the site?
Will all the links and SEO be disturbed, if I just transfer all files to my server?
there is no way to directly copy the site if you don't have access to the server. What you can do is replicate the site. In other words, copy paste all text and images down from the old site. It sounds like you have already done that. Then you set up a fresh WordPress installation on a new server, install the same theme and plugins as you had on the old server and then copy paste in all text and images that you saved previously. Then you can register your site with for example Google Search Console and via that keep track of which URLs that are now returning 404 and set up redirects or new pages for those URLs.

wordpress: domain mapping and site URL display

i am a wordpress newbie and have not much experience with their settings. Basically, i have recently set up a domain mapping for an existing wordpress site that i took over and that i had to move to another host, so domain mapping seemed to be an easy option to point the old URL to the new host. I have set up the domain mapping to point to the new site from:
http://www.myOldExample.com
to the new one:
http://www.myNewWebsite.com/foldername
So far the content migration worked in wordpress. The problem is that when i type in the old URL in the browser, it redirects the old page and shows the new site for the main home section as expected, but for all the subsequent links such as About, Contact, Products etc. it shows the new URL with the subfolder path, whereas i would like them to display the old URL as the base URL, so i am not sure if i need to change anything on the domain mapping site, or does this need to be done on the wordpress side? Does wordpress offer something like a base URL rewrite? I could only find in the general settings the Site URL and Wordpress URL, but i am not sure if changing those values to point to the old URL would break the site.
Many thanks for any ideas.
I think, this is url problem. When you are migrating wordpress site from one server to another server or same server but different folder, so its create url problem like http: //theoldserver to, for example, http: //thenewserver.com is problematic. So download file from this site and put this file, where blog files placed on server. Then do step, which define on this url.
This is very handy tool
Search and Replace for WordPress Databases Script" tool that's very handy (make sure to read the instructions and have a backup of the db before using it).

Changing base domain / allowing multi base domains

I have a new client that I am converting over to Drupal from Wordpress. We have two domains with the same name but different TLDs i.e. .com & .org. We have decided to start by setting up the site first under the .com so we have a live site to play with during the development.
So we currently have a wordpress site running on the .org and drupal (on a new host) running on the .com domain.
So two questions:
Can and How do you configure Drupal to work for both the .com and the .org ?
Can and How do you change the base domain drupal is configured with after the site is live ?
If you aren't using Drupal's multisite system (that is, the site information is being put into sites/default instead of sites/example.org or sites/example.com), this is really easy: do nothing. There is no step 2. Drupal will handle any domain thrown at it: just use your web server's name-based handling to determine which domains to accept.
If you are using Drupal's multisite system, it's a little harder:
Rename the sites folder (so from sites/example.com to sites/example.org).
Drupal's files table hardcodes the files directory it uses, so you're going to need to change all the paths in it. Run UPDATE files SET filepath = REPLACE(filepath,'example.org','example.com') on the database.
The other place to change the path is under Site Configuration -> File system.
The final place you're going to need to change paths is going to be on the settings page for your theme if you decided to use a custom logo or favicon.
Once you've changed all the paths, rebuild the cache under Site Configuration -> Performance.
This should cover most cases. Check with the third-party modules you're using to see if they also hardcode filepaths. If the modules are using the API correctly, they should've been handled in steps 2 and 3.
Because of all the hardcoded file paths, I highly recommend not using multisite unless you really need to. If you are only running one site in a Drupal install, just stick the site in sites/default.

Resources