This may be a potentially really, really dumb question.
So my CI project is going to be our main company website. I have created it here:
www.example.com/CodeIgniter_2.1.3
How do I get my users redirected to that when they just visit www.example.com/ and have it stay www.example.com in the URL?
Is this a .htaccess file thing? Or do I need to move my folders up a level?
CodeIgniter's default behavior is to hide it's actual path. You should only need to copy the .htaccess to the document root, and modify the path to include CodeIgniter_2.1.3
i.e:
RewriteRule ^(.*)$ /CodeIgniter_2.1.3/index.php?/$1 [L,QSA]
So you have put the CI files in a directory called Codeigniter?
Related
I have a CakePHP application that uses themed views, css and images. Now I need to have themed robots.txt as well.
Naturally I put a robots.txt file in every theme folder /View/Themed/Theme/webroot/robots.txt, but only the one in the app/webroot gets displayed. Usually themed files (img,css,js,ctp) will overwrite the "default" files.
Is there a way to have different robots.txt files?
note: before I used to have something like this in the htaccess file
RewriteCond %{HTTP_HOST} ^bla.website.de$
RewriteRule robots.txt bla.robots.txt [L]
RewriteCond %{HTTP_HOST} ^foo.website.de$
RewriteRule robots.txt foo.robots.txt [L]
RewriteCond %{HTTP_HOST} !^www.website.de$
RewriteRule robots.txt noindex.robots.txt [L]
But this will get out of hand very fast.
Themes don't work like that
Usually themed files (img,css,js,ctp) will overwrite the "default" files.
Actually, that's not the case. CakePHP can only handle requests that reach the php code, if there is a static file matching the path in the way, that will get served directly by the webserver, as that's what the default rewrite rules implement.
When using a theme CakePHP will change the requested url i.e.:
app/Plugin/DebugKit/webroot/js/my_file.js becomes app/webroot/debug_kit/js/my_file.js
app/View/Themed/Navy/webroot/css/navy.css becomes app/webroot/theme/Navy/css/navy.css
So it is not that the response for assets (/css/somefile.css) is modified, an entirely different request (/using_this_theme/css/somefile.css) is made when using a theme.
This is, in fact, something you're expected to take advantage of, by putting or linking your theme assets directly in the webroot as serving files via php is slower than not invoking php.
Use a route and a controller action, not rewrite rules
Since you have a multiple-domain-points-at-one-application setup (implied) and want a single url (/robots.txt) to return different content it's not possible with the default rewrite rules to make the url point at a static file1. To make the contents of /robots.txt dynamic, simply delete the file in webroot/robots.txt and add a route and controller action to handle serving the content based on the theme that's relevant to the request.
1 Obviously it is possible to do it by changing rewrite rules, but that means added complexity, and prevents the response being configurable (using a different theme -> instant change of content). You could consider generating your rewrite rules programatically though
I have CakePHP in a subfolder public_html/cakedir, the folder being accessed from http://cakedir.mydomain.com. Everything seems to be working so far except that the static files are not being found, giving me 404 on the css files.
I'm unable to find anything useful on this issue, though it seems like something straightforward, so perhaps I'm just searching the wrong terms.
Thanks
This was a problem with the .htaccess file in webroot. Add RewriteBase /cakedir/app/webroot/ after RewriteEngine On and it'll work!
I have a website which was built by CakePHP. I want Blog section to be built with Wordpress so I upload a Wordpress folder to /app/webroot/ folder and rename it to 'blog'. I installed Wordpress normally. In the homepage, I show the link to Blog section with the code
<?php echo $this->webroot. '/blog'; ?>
I have checked it and it showed 'http//mydomain.com/blog' but I clicked that link, it automatically redirected to 'http//mydomain.com/app/webroot/blog'.
I just want the link to be redirected to 'http//mydomain.com/blog'. How can I do it?
P/S: I am sorry for my bad English.
Sounds like, when you ran the WP install you didn't go into the database and change the url paths to /blog. This article should help.
http://www.balistupa.com/blog/2010/08/how-to-redirect-appwebrootblog-into-blog-wordpress-cakephp/
I have some blog in my webroot and have added the following to my
htaccess:
RewriteCond %{REQUEST_URI} ^/blog/(.*)$
RewriteRule ^.*$ - [L]
And this is fine if I type:
www.mydomain.com/blog/
However if I dont put the trailing slash (www.mydomain.com/blog) I
get redirected to:
www.mydomain.com/app/webroot/blog/
I have installled my Cakephp based website on my production site like following way
var/html/
app/
cake/
.htaccess etc
Its working perfectly untill I installed Blog. To make it work, I moved my content of blog folder to webroot, now my structure is
var/html/
app/
webroot/
blog/
cake/
.htaccess etc
This works thanks to those .htacess files
Now I am making a subdomain "m
"
ie http://www.m.example.com
My questions are...
Am I doing it right way?
Should I just move every subdomain etc to webroot?
Should I modify htaccess to acheive followwing structure
var/html/
app/
webroot/
cake/
.htaccess
blog/
m/
subdomain/
I would recommend separating them like this. The cake1.3 could be any name you want but the idea is that each framework should have its own descriptive folder.
This makes it much cleaner and is definitely necessary when you get into adding your projects to repositories like git. Each folder can then have its own .htaccess files and being separately configured in your apache config.
var/html/
cake1.3/
app/
webroot/
cake/
blog/
I've copied a homepage to the server, after a few problems with 1&1, if this matters, I've changed the .htaccess in the root, /app and /app/webroot directories. After
RewriteEngine on
I've included
RewriteBase /
to get it to work. However, beside the homepage itself, I've made an administration by adding a new CakePHP-project in the folder "Administration" which I've simply copied in the root-directory. Worked perfectly with XAMPP, but unfortunatly not with the 1&1-server. I've also tried to copy it in the app-folder, but visiting example.com/Administration will just give me an error, that says, the controller cannot be found.
Any ideas how I could access my administration?