How to set CodeIgniter to ignore Wordpress folder? - wordpress

I built a website with CodeIgniter last year www.example.com, and client wanted Wordpress Blog last week. I built the blog and uploaded to www.example.com/blog
Now when I click any link on wordpress it gives error as below :/
http://www.example.com/blog/category/one-last-category/
An Error Was Encountered
Unable to
load your default controller. Please
make sure the controller specified in
your Routes.php file is valid.
How can I set Codeigniter to ignore Wordpress folder?
Appreciate helps!!!

You'll want to do this with an .htaccess file (assuming your web server supports it.) For example, in the DocumentRoot of my Codeigniter site I have an .htaccess file which contains:
RewriteEngine on
RewriteCond $1 !^(index\.php|static|user_guide|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
This allows me to still access static files and the CI user guide. In your case the RewriteCond would be something like:
RewriteCond $1 !^(index\.php|blog)

Related

Wordpress page not taking precedence over server directory

On my wordpress site, I have a page mysite.com/download. On the same server I have a directory named download, where I store files which I need to provide on download page. So the problem is that when someone tries to access mysite.com/download, he's taken to the directory instead of the page. I have turned off the directory access for now, so it currently displays no permission to access. I want wordpress to display the page instead of the directory. I am not sure if it's a problem with the server or wordpress. I hope someone can clarify.
Try to put a redirection rule to your download.php file like this using .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/download.php$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /download.php [L,R=302]

WordPress in base.example.com and accessible from example.com give me path issue in Hostgator

I have a WordPress installation at Subdomain. I wish to have the website display the site at example.com
The WordPress folder is located at base.example.com and the path is public_html/folder1/base.
If I run the site from the subdomain with home and site url pointing to base.example.com everything works fine. If I change the second url to my root example.com copying index.php (changing the path) and .htaccess to public_html/ I get the following issue:
.htacces is not writable from wordpress
tons of redirect issue
admin bar disappear (solved here Admin bar doesn't appear on the front-end of a WordPress website)
if I open the customizer I get errors (TEMPLATE ISSUE... with default wp themes everything works)
Using USERPRO Plugin to manage my user after login I'm redirect to the default wordpress login page (that means there is something missed up in url redirect) EDIT: This is the path on the login page that appear after userpro login: http://base.exaple.com/wp-login.php?redirect_to=http%3A%2F%2Fbase.example.com%2Fwp-admin%2F&reauth=1 ... I'm still waiting for an answer from the author
sometimes when I press logout it just reload the admin page.
when I visit base.example.com I'm not redirect to example.com... is this right? it shouldn't redirect me instead?
Are 5 days that I'm trying to solve it so I also wrote to hostgator support because I think I did everything in the right way but they just say they can't support issue wich came from customization....but this is not a customization, is just making work a simple wordpress installation from a subdomain!!!
Hope you can help me!
EDIT
.htaccess (both in public_html/ and in public_html/folder1/base are the same)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %.{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
index.php (in root)
require('./folder1/base/wp-blog-header.php');
index.php (in public_html/folder1/base)
require('./wp-blog-header.php');
EDIT 2
I just get some 404 errors...
Updated question 4,5,6
Your suggestion doesn't work. 301 redirect force wordpress to find his files in public_html instead the installation folder and obviously it can't find anything giving me an error. I've also changed the url form example.com to base.example.com but nothing!
I've tried to install wordpress in a simple subfolder and all the issue disappear but as I'm stubborn I want to achieve to make wordpress working in a subdomain instead a subfolder...
.htaccess being writable is not unusual, being that the site is in a
different directory.
Tons of redirect issues isn't a question, I would need an error to help you solve that problem.
Solved by my answer at Admin bar doesn't appear on the front-end of a WordPress website.
This isn't a question, I would need an error to help you solve that problem.
You should contact the UserPro support team via their CodeCanyon account for support with their product.
What error occurs when you are unable to logout? I would need an error to help you solve that problem.
This is normal behavior. You can change this through a 301 redirect in your .htaccess within the root of the subdomain folder (not the root of your website). This code excludes /wp-content/* (for uploads access, plugins access, theme file access, etc.), /wp-admin/* (for admin access), and /wp-includes/* (for important WordPress includes access). Try this code and see what happens:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/wp-content/
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteCond %{REQUEST_URI} !^/wp-includes/
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Fishpig Wordpress Magento - http://example.com/blog resolves to www.example.com rather than www.example.com/blog

I have a working Fishpig Wordpress Magento instance on a production server.
All the green ticks show it has succesfully configured and when visiting
http://www.example.com/blog
it works. However when I try and and visit
http://example.com/blog
it sends me back to the magento home page at www.example.com .
I have tried setting the url in wordpress to both http://example.com/blog and http://www.example.com/blog but in both situations it always sends me to the home page at site.com.
This is a concern because most experienced web users will not type www when trying to access a location.
My htaccess is as generated by Wordpress and looks like
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
#wp generated
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Please not the wordpress site files are located at site.com/wp and it is the fishpig extension which arranges the direct from the non existent /blog path.
First of all, to start of, one way to resolve the issue is to simply make your Magento website DEFAULT to not have the www. in the url.
In Magento, go to System > Configuration > Web.
In the "Secure" and "Unsecure" tabs, find "Base URL."
The value should look something like this:
http://www.site.com/
Replace ALL references to the domain so it shows:
http://site.com/
Unfortunately, there may be a lot of appearances of it throughout the site. You'll need to do the same thing elsewhere on the server.
If you really want your site/blog to say www., though, you'll have to properly forward the .htaccess file in Magento. I'm not too keen on how Magento's .htaccess file works, but I do know how to forward a url and keep all of its additional pages as well (however, Magento's setup may interfere).
The code should look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.site.com$1 [R=301,L]
Again, I don't know how well this will work with Magento's set up, but I've successfully used the above code to redirect url's to the correct url I want. That code above was actually used on a wordpress site, though.
Check for Rewrite rules in Magento's .htaccess file and try putting this above it. Be careful, though; it is VERY easy to cause 500 internal server errors if you mess up the .htaccess file, so always keep a backup.
Try this out and I hope it helps.

Wordpress installed in root folder, subdomain now not working, GoDaddy host

please forgive me for being a complete beginner at this, I'd rather not have to try to deal with this myself but as GoDaddy support have not replied after 2 days I'm going to have to. I think my problem is the same as the one above, but I'm not 100% sure, so I'm reposting it, I'm not really confident enough to attempt to try the fixes I've seen here so I need someone to give me baby instructions?
Our original website (www.mwpics.com.au) was built in Dreamweaver etc, recently we created a new website in Wordpress, in a subdomain, then migrated it over to the root folder where it is now operating fine. I also moved the files for the old website into another directory which I called 'old', so they're all still there.
The problem is that I have a subdomain set up - which is still showing as set up in the control panel on godaddy the url is www.mwpics.com.au/clients and it is at www.clients.mwpics.com.au. This directory contains loads of other directories, each of which is password protected by .htaccess files and which our clients access directly (not through the site) to download their finished work. The test one and the one for random clients is www.mwpics.com.au/clients/temp - username and password both temp (the usernames are all the same as the directory names).
Since the WP install to the root directory the /clients extension no longer works (it should bring up an information page which is an .html index page in the directory) and the /clients/name extensions no longer works - it goes back to the wp site with a 'not found' error message. Strangely it does bring up the box for the username and password, but when you enter it it just goes back to the 'not found' message.
Someone told me it was the .htaccess file - so as an experiment, I renamed the .htaccess file in the root directory and then copied the .htaccess file from the old root files into the root directory, eureka! It worked - and also the WP site opened to the home page... but bummer - the /pages in the WP site now no longer worked! But at least I know the source of the problem.
So I switched it back and this is the status quo - I have no idea how to fix this, and with everyone back at work tomorrow, clients are going to want to start downloading their stuff...
Can anyone help me? I'm starting to panic a bit
you only have to exclude the clients subfolder in your wordpress .htaccess - see .htaccess & Wordpress: Exclude folder from RewriteRule for a detailed description
this should work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/clients.*
RewriteCond %{SERVER_NAME} !clients\.yourdomain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
short: it simply skips the wordpress rewrite rule if the reqest uri starts with /clients or the domain name is clients.yourdomain.com
be aware though, that as soon as you update your wordpress permalink settings, this rule will be overwritten by wordpress ...
Try adding the following at the top of your root directory's .htaccess file, before the WP code block:
<IfModule mod_rewrite.c>
# fix rewrite for GoDaddy
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} clients.mwpics.com.au$ [NC,OR] # ignore subdomain
RewriteCond %{REQUEST_FILENAME} -d [NC] # ignore directories
RewriteRule .* - [L]
</IfModule>

Using .htaccess to redirect if file isn't found with Wordpress

I have an issue where we are merging a website with Wordpress. The website has a ton of news stories in a "/news" directory that we need to keep. When we add the CMS at say "/wordpress" we can set the base URL to the root of the directory so when we make a new post in the category "news", the link for it is "/news/this-is-the-post-title", except the REAL location is "/wordpress/news/this-is-the-post-title". So my issue is that we want to keep all news stories at the "/news" URL, and in my head we just need the .htaccess to say "if the requested URL doesn't exist in the /news directory, try /wordpress/news", and of course if Wordpress doesn't find anything, it can 404. Hope this makes sense, thank you!
I don't fully understand how the original news stories are held. But, if they are grabbed with PHP then you should be able to redirect to /wordpress/news/post-title if it doesn't exist.
On the other hand, if the news stories are static files you can check for them with .htaccess and make sure the file exists on the server.
# Goes in the "news" directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news
# These make sure the file or directory doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect to /wordpress/news/whatever-entered-goes-here
RewriteRule ^(.*)$ /wordpress/news/$1 [L]
</IfModule>
Reference: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
If you only use WordPress and static pre-existing directories and files (and not another CMS, next to WordPress), you can probably just follow the directions on giving WordPress its own directory. All WordPress files go to wordpress/, only the index.php and .htaccess are copied back to the root directory. The standard .htaccess from WordPress already has the two RewriteCond rules that check for existing files, so if the request is for news/happy-2010.html and this file already exists, your server will just serve this and not start WordPress.

Resources