Codeigniter - 1 project - several domain names and several IP - codeigniter

I have 1 dedicated server.
The server has several IPs.
Some IP are dedicated for one particular domain.
Ip1 = mysite.be
Ip2 = mysite.fr
Ip3 = mysite.com
There is only one project. Each domain goes on the same location
My website is on /var/www/vhosts/mysite.com/httpdocs
For all other domain, i create a symlink.
/var/www/vhosts/mysite.be/httpdocs -> /var/www/vhosts/mysite.com/httpdocs
/var/www/vhosts/mysite.fr/httpdocs -> /var/www/vhosts/mysite.com/httpdocs
...
When I go on mysite.com, all works.
But when i go on mysite.be ... I have an output from codeIgniter :
No input file specified.
I search more information about this error and I see that : https://stackoverflow.com/a/14578219/905867
My .htaccess fil is already well configured... I guess
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|css|js|uploads|modules|public|timthumb\.php|\.htpasswd|google.*\.html|captcha)
RewriteRule ^(.*)$ /index.php?/$1 [L]
The fact that the domain linked with symlink display the error "No input file specified." proves that the symlink is OK and the acl on server are OK too (chown and chmod).
I think it's a little thing, but i don't know what. Anyone has a idea please ?
Some others information :
- I manage my server with plesk 11.0.9 #53
- My domain are "php as FastCGI module". If I use "as Apache Module, there is a blank page instead of error "No input file specified."

It takes me long time but... problem is solved.
No input file specified wasn't a CodeIgniter error but a CGI/FastCGI error...
So I check on my plesk an I saw the domain are "PHP as FastCGI module" instead of "PHP as Apache Module".
But... instead of an error, I have a blank page.
Then I thought about open_basedir restriction. It was configured on "Webspaceroot" instead of "Docroot"... and "abracadabra" it works.
Take care !

Related

apache2 silent redirection not working as expected

I have a web server using apache2, and I want to silently redirect some pages.
So if an user try to access "http://website.com/test.php", the page at "http://website.com/fool.php" will be used instead. And i need to do that for several pages, not just test.php.
I though I could use the mod_rewrite module for this purpose, but I cant get it working.
I tried adding in apache2.conf, so i could have at least just a redirection for now (not silent):
RewriteEngine on
RewriteRule "^/test.php$" "/fool.php"
or
<Directory "/var/www">
RewriteEngine on
RewriteBase "/var/www"
RewriteRule "^/test.php$" "/fool.php"
</Directory>
This result in the test.php not being redirected at all (it still can be accessed), but also, it breaks my custom 404 and 403 pages with the error "ForbiddenYou don't have permission to access this resource.Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.".
Apache2 is not complaining about the syntax when i restart it.
Setting it in my sites-enabled config leads to the same result.
Note that the goal is not to prevent the direct access to test.php, and the request must result in a 200 success code.
There may be something i do not understand, because searching on the net, it looks like it's the way to achieve this.
You may try an alternative method: use the .htaccess file. (place the file in the root directory of your site)
For example:
RewriteEngine on
RewriteRule ^/test.php$ /fool.php [L]

Transferring codeigniter HMVC project from localhost to live server

I made a web application on codeigniter HMVC. I tested it on local server and the following link works perfectly fine by giving me a login form, the link : http://localhost/bird_vision/users/login, where my directory structure goes like this bird_vision/application/modules/users/users.php (users->module's name, users.php->controller's name). Now I posted the whole "bird_vision" folder to web using filezilla.
- changed the base_url in config.php file to domain_name
- Made some changes in .htaccess file
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$10 [L,QSA]
</IfModule>
Now when I write bird_vision.se/bird_vision/users/login in my address bar it gives me 404 page not found. Although when I when type birdvision.se/bird_vision/welcome it gives me welcome to codeigniter page.
Please I need help as my all hardwork making this project is at stake. Thanks in advance.
I figured the problem was not with HMVC but was with codeigniter version 3.0. When it comes to unix(which was the operating system running on my server), it is case sensitive. So when I tried to access the controller it could'nt find the file because of case sensitivity and a 404 popped out everytime.
My folder structure before was something like :
-application
-->modules
--->users
---->controllers
----->users.php
And the link on which I was getting 404 was www.example.com/users/login
where "users" in the link is controller's name within the "controllers" folder under "modules" folder in my case named as users.php and "login" is the function inside the controller.
All I had to do was to change the case of the first letter of my module and controller name. Now my directory looks like
-application
-->modules
--->Users
---->controllers
----->Users.php
note : capitalized "U" in Users module and Users controller.
And the the url I used to access the users controller was : www.example.com/Users/login
And I was back in business.

url rewrite debian

I just got fresh debian VPS into my hands.
I installed url rewrite and simple things like this does seem to work
RewriteRule ^login$ /login.php
However this doesn't work:
RewriteRule ^cats$ /index.php?cat=cats
Anyone have idea why?
(it works on local xampp server + it worked on shared host I had)
Thanks
First of all make sure that you have mod_rewrite, and it's on. To do so, create an empty Php file, then add <? phpinfo() ?> and diplay it in your browser.
If it's "on" then you can go on.
If it's in a .htaccess file then try with / without the slashes.
RewriteRule ^cats$ /index.php?cat=cats
Or
RewriteRule ^/cats$ /index.php?cat=cats
And if that's not enough:
Two hints:
If you're not in a hosted environment (= if it's your own server and you can modify the virtual hosts, not only the .htaccess files), try to use the RewriteLog directive: it helps you to track down such problems:
# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
My favorite tool to check for regexp:
http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

apache returns 404 even after mod_rewrite

I am using apache mod_rewrite for the first time.
I want http://example.com/anything/after/this to be transformed as http://example.com/storage-server/index.php?id=/anything/after/this
I have written following lines to apache's httpd.conf file
RewriteRule ^/(.*) /storage-server/index.php?id=$1
But I am getting 404 message saying that this file doesn't exist. I have enabled the mod_rewrite so that is not issue. I think something is preventing this URL to be rewritten....
any idea???
UPDATE::
All things are solved. All above mentioned settings should be entered into /etc/apache2/sites-enables/000-default file..
SOLVED
UPDATE:::
I have just tried extremely simple rewrite rule. I have created test1.html and test2.html files in my web server root. Then i wrote following rule in my httpd.conf file
RewriteRule ^test1\.html$ test2.html
When i visit test1.html the browser still shows test1.html file instead of test2.html/ Please help.. I am having this trouble since last 3 days... sick of it ..:-(
You write that you want it to redirect to http://example.com/index.php?id=/anything/after/this but you're redirecting to http://example.com/storage-server/index.php?id=/anything/after/this. Could that be it?
ensure that the following line in your Apache's httpd.conf is not commented out
LoadModule rewrite_module modules/mod_rewrite.so

Reaching files outside od the documentroot scope

I'm writing a script to build a dynamic website,
the website is created by loading external components.
The DocumentRoot is location at /sites/website/public
the components directory is located at /sites/website/components
i wannna reach the data directory of each component depends on the requested url.
for example:
the url:
http://ibuildmywebsite/component-data/randomimage/demo/swan04090044_small.jpg
should fetch the file /sites/website/components/randomimage/data/demo/swan04090044_small.jpg
how can i achieve that ?
i would prefer a way that can be placed inside .htaccess (if there is one) instead of modifying the virtual host definitions.
Thanks!
Combine RewriteRule with Alias maybe ?
Alias /randomimage /sites/website/components/randomimage
RewriteRule ^component-(.*)/randomimage/(.*)$ /randomimage/$1/$2 [R,L]
(Won't work in .htaccess though)
You could probably also use Symlinks with:
Options +FollowSymLinks
And link dynamically components-*/randommimage/* to /sites/website/components/randomimage/*/*/

Resources