I am building a site that will (obvisouly) have a front end public portion that I want to drive with Concrete5, but then it will also have a members section that I would like to build with Code Igniter.
Does anyone have any idea how I could do that?
I guess I could just throw the Code Igniter code into a sub directory, but would I run into any issues with that?
i can't see why not.
As you suggested a separate folder on the site would be one solution.
(you might have to tweak the .htaccess file (if you are using one) to ignore the other cms/framework
Another solution would be to have separate subdomains,
eg example.com and members.example.com
The answer, since the OP hasn't posted it, is to change the .htaccess rule:
RewriteBase /
to:
RewriteBase /foo/
where foo is your subdirectory that the index.php and CI reside. This .htaccess should also be in the same folder as the CI index.php. Works like a charm. Also don't forget to add the subdirectory to the base_url config setting.
I ended up using a sub directory for Code Igniter. I had to change the .htaccess file and Mod_Rewrite rules for apache in order for the Code Igniter "pretty" URLs to work correctly.
I will post the code later if I remember.
Related
I had to add a PHP file within a Wordpress installation. I have created a subfolder and the file works fine, but I need to make it "pretty" according to Wordpress permalinks style.
In few words:
https://example.com/php/partners.php
must become https://example.com/our-partners/
How can I do it? Where should I place the .htaccess file? In the root as it is now or will I need another one in "php" folder?
Thank you!!!
Max
Easy way make wordpress template in theme.
Put below code at the top of the php file in comments
<?php /* Template Name: logicdigger */ ?>
Then move your file in to your theme.
Go to add page and create new page then select template from right side of your screen. THAT'S ALL
Complete article here
You will edit the existing .htaccess file in the root. Something like this should work:
RewriteEngine on
RewriteRule ^/?our-partners/?$ /php/partners.php
Requests to /our-partners and /our-partners/ (with or without trailing slash) will point to /php/partners.php. This also allows for query params in the URL if needed: /our-partners?foo=bar
This requires mod_rewrite to be enabled in apache. The docs for RewriteRule can be found here
So, I have the current file structure:
ROOT
-> /public
-> /user_views
user_handle.php
user_profile.php
user_feed.php
user_settings.php
.htaccess
As you see, the folder user_views contains a few of the possible views that the client could want to look at. What I am wanting, is for clients that insert the URL http://example.com/user/ to be directed to the page user_handle.php. This handle would act as a root file for all /user/ pages, and it would accordingly split into those pages through numerous $_GET requests.
So far, I have the following .htaccess, but it's not working...
RewriteRule ^user/ user_views/user_handle.php [L]
What could I do to get this to work, so that the url http://example.com/user redirects to the user_handle file in the user_views folder?
Thanks!
I'm not sure I fully understand your question, but it seems you would like to make user_handle.php located under public/user_views act as a "router" for the rest of you PHP files and have all requests to /user/ (e.g. /user/?page=1) be processed by user_handle.php.
If that's the case, your rule seems legit. The only thing I noticed (I might be wrong) is that your .htaccess is located outside the public folder. In that's the case, you need to include 'public/' as part of your rule.
I recreated the folder/file structure you described and it has worked for me using the following .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^user/ public/user_views/user_handle.php [L]
</IfModule>
Slight chance this is the problem, but you also might want to double check that mod_rewrite, which is the rule-based rewriting engine is enabled on your server/local environment. It should show up under 'Loaded modules' when you call phpinfo() in any PHP file.
Hope this helps.
my framework is codeigniter and my site works fine.
example :
www.example.com/
now,I have copied all my codeigniter's folders to another dir like this:
www.example.com/test
now my urls:
www.example.com/profile //works fine
www.example.com/test/profile //not work
I get 404 page not found .
I changed base_url to :
$config['base_url'] = 'http://www.example.com/test';
where is my wrong?
please have a look at your .htaccess file. Because it'll be in the RewriteBase condition in there. Check it and tell what You found.
Codeigniter does not support multiple subdirectory levels in your controllers
But still you can extend it.
You might have to extend Router Class
Do you still have all CodeIgniter files in your main directory?
If yes, then you must remove them or you can create SUBDOMAIN to solve the issue.
Note: Codeigniter don't support multiple subdirectory levels in your controllers.
If no, then you must look for your .htaccess file, it'll be the RewriteBase condition in there.
I have been using code igniter as a subdirectory of a site and have several instances of if on one server. Each instance is considered a separate application, but all under the same domain name. I am looking to enable a slightly different URL structure though and have turned to mod_rewrite to help me out.
The page is reachable at http://localhost/test but I want to rewrite that URL to appear as http://localhost/en-US/test.
The problem is I keep getting a code igniter (CI) 404. I can confirm the mod_rewrite is reaching the CI index.php, but CI is failing to deliver the correct page. Here's and example setup:
1) Download a new instance of CI and place it in a subdirectory in the site root. Name the CI folder "test". It should be reachable now on a local server at http://localhost/test and you should see the default welcome view.
2) Create a .htaccess file in the server's root web directory. DO NOT place it in the CI "test" directory. Add the following lines to it.
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/test/?$ test/index.php [NC,L]
From my understanding of mod_rewrite, this should allow the URL http://localhost/en-US/test to render what is located at http://localhost/test. It doesn't though. I just get the CI version of a 404. I need help figuring out how to resolve this.
Hmm your question made me install CodeIgnoter and read its routing :)
Anyway have your DocumentRoot/.htaccess like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/(test)/(.*)$ $1/$2 [NC,L]
Then replace this line in your /test/application/config/config.php`:
$config['uri_protocol'] = 'PATH_INFO';
It is by default set to:
$config['uri_protocol'] = 'AUTO';
After this you can open this URL: http://domain.comen-US/test/ to load CI home page in /test/ dir.
You should check out routing. Place this statement in your config/routes.php file AFTER the reserved routs.
$route['test'] = "en-US/test";
You can forget about htaccess when you have Codeigniter (most of the times).
I'm having a scenario where I had to deploy multiple directories for different languages. Development has initially centered on one of those languages, and just one part of the whole site is a small CI app.
I'm trying to avoid copying the whole app for the several other languages, and redirecting to it with an .htacces. The latter is working fine, but CI returns a 404 error when accessed from a URL different to the real one.
My best guess is that certain configuration files must exist with unique properties that configure the additional root URLs, but I don't know where to start (and Google didn't come up with a similar scenario).
File Structure:
public_html/
lang1/
app/
(the actual CI app)
other static stuff...
lang2/
app/
.htaccess (redirecting to /lang1/app/)
other static stuff...
lang3/
...
Additional info:
The $config['base_url'] is set to http://.../lang1/app/.
The .htaccess:
RewriteEngine on
RewriteRule ^(.*)$ /lang1/app/$1 [L]
I was able to accomplish this by my own. For those who might find this question in the future, these are the steps to access your application from a different directory. Considering the scenario introduced in the question above, the following example will work for the deployment of of a ghost version of the app in the lang2 directory:
1.- Copy only the index.php file from the root of your CI installation (from lang1/app/index.php) to the lang2/app/ directory.
2.- Edit the following lines:
$system_path = '../../lang1/app/system';
$application_folder = '../../lang1/app/application';
//Even if the documentation suggests the necessity of a _full path_,
//this works perfectly well for 2.1.0
3.- Add any configuration you may want to have set explicitly for said subdirectory, these will be set to $this->config, replacing the values set in the config file in your base application:
$assign_to_config['lang_version'] = 'lang2';
4.- You have to set a proper base_url. In this case, we could reuse the lang_version config we just included. This way, we can forget about this line in the next languages we need to create.
$assign_to_config['base_url'] =
'http://www.example.com/' . $assign_to_config['lang_version'] . '/app/';
5.- Create an .htaccess file inside lang2/app to make sure that any static assets (js, css, images) accessed by the HTML are get from the actual assets folder inside the original app directory, like in lang1/app/assets:
RewriteEngine on
RewriteRule ^assets/(.*)$ /lang1/app/assets/$1 [L]
6.- Add to this .htaccess your usual rule to keep your URLs friendly, but this time directing all traffic to the ghost copy of your app:
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /lang2/app/index.php/$1 [L]
7.- Grab a beer or any other beverage you drink to celebrate success, always respecting your local laws. Profit. Your controllers will have to read the config('lang_version') value to present the content in the proper language to the user. You may use the included language helper for that, or any other solution you prefer.
Why would you do this? Theres a thing called i18n.
http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n/
Why not use this? Didnt copying the app folders seem a bit tedious to you? Theres a language helper for a reason.
I hope this helps.