I'd like to know if it is possible to organize the following structure of the CodeIgniter installation:
- Main folder
-- codeigniter
-- images
-- site1-application
-- site2-application
-- site1-index.php
-- site2-index.php
The main idea is to use the same images and codeigniter folder across the multiple web sites for easier maintanance.
For now I do have two web sites that are resides in two standard installations and I'm unable to share the images folder nor to update system libraries simulaneously at multiple web sites.
I've played alittle with the .htaccess file, but no luck for me :(
Thanks in advance!
Default recommended CodeIgniter .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#CodeIgniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^$ /index.php [L]
</IfModule>
Tweaked CI .htaccess file for your purposes (you know, a year too late):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#CodeIgniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Check for Domain 1 with a path
RewriteCond %{HTTP_HOST} domain-1.com
RewriteRule ^(.*)$ /site1-index.php/$1 [L]
# Check for Domain 1 without a path
RewriteCond %{HTTP_HOST} domain-1.com
RewriteRule ^$ /site1-index.php [L]
# Check for Domain 2 with a path
RewriteCond %{HTTP_HOST} domain-2.com
RewriteRule ^(.*)$ /site2-index.php/$1 [L]
# Check for Domain 2 without a path
RewriteCond %{HTTP_HOST} domain-2.com
RewriteRule ^$ /site2-index.php [L]
</IfModule>
Yes, it's possible.
Use .htaccess to direct all trafic from one domain to site1-index.php and all traffic from another domain to site2-index.php.
The location of CI Application and System folders is set in the *-index.php files.
Related
I have a cakephp application running on shared hosting server. Now I want to add a staging server for testing purpose. I defined a subdomain, and made changes in htaccess files, but these things don't work. Please suggest what should I change more.
I know similar questions have already asked on stackoverflow but nothing works for me.
sudomain name staging.example.com
Here root folder .htaccess code is mentioned here:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and .htaccess file from app/webroot from staging:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Is there any issue with such code or have to add more changes in another files.
Library is also installed in subdomain. Version of cake is 2.5.
This condition:
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
will not match your subdomain hence RewriteRule won't fire.
Just change your rule to this:
RewriteEngine on
RewriteRule .* app/webroot/$0 [L]
So I need to do a .htaccess file that allow me to redirect the images link folder (wp-content/upload/) from a different site (http://widesigner.com.br/alessandra/) to be this one (http://www.alessandratonisi.com.br/site/)
Basically it's redirect some image links, example:
http://www.widesigner.com.br/alessandra/wp-content/uploads/2012/03/MG_6058-600x400.jpg
http://www.widesigner.com.br/alessandra/wp-content/uploads/2012/03/MG_9515.jpg
to
http://www.alessandratonisi.com.br/site/wp-content/uploads/2012/03/MG_6058-600x400.jpg
http://www.alessandratonisi.com.br/site/wp-content/uploads/2012/03/MG_9515.jpg
So what you need is redirect a website domain to another one for a specific folder. I don't know if the next line will help you to solve the problem, I don't think that will be the solution since I didn't test it.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/alessandra/(.*)$
RewriteRule ^(.*) https://www.alessandratonisi.com.br/site/%1 [R=302,NC]
Here are a lot of examples that could lead you to the correct answer: https://gist.github.com/ScottPhillips/1721489.
UPDATE:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/alessandra/(.*)$
RewriteRule ^(.*) https://www.alessandratonisi.com.br/site/%1 [R=302,NC]
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>
# END WordPress
I'm attempting to remove index.php using the CodeIgniter framework (hosted with GoDaddy - Linux), which is currently installed to: example.com/ci
I've already declared the base_url in application/config/config.php as http://example.com/ci/.
The following is my latest test input for .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Keep in mind that the domain CI is installed under is not my hosting root. The actual path for the CI folder would be: root/mydomain/ci
After spending the better part of the day today trying a plethora of "solutions", I'm beginning to wonder if this is possible to do with GoDaddy at all, or perhaps my situation is somehow unique.
Any advice would be greatly appreciated!
EDIT: The closest I've come to fixing this issue is using the following .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /clone/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^index.php/(.*)$ [L]
</IfModule>
.. while setting my base_url to mydomain.com/clone/ (using http:// of course) and removing index.php from index_page. Navigating to mydomain.com/clone works fine but navigating to the two pages that are part of the software results in a 404 page.
An answer to your comment, you need to add a rewrite condition to access the sites/ directory. CodeIgniter is looking for sites in the controllers folder.
RewriteCond $1 !^(index\.php|sites)
You can also add the names of your resource folders like images/video etc.
Change this
In your config.php
$config['base_url'] = '';
$config['index_page'] = '';
then in .htaccess
RewriteEngine on
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
or else you can use your .htaccess too
EDIT 01
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have assets.domain.com hosting all my images, typefaces, scripts, etc. for a Wordpress installation on the top-level domain. I want to redirect any access to subdomain and folders to top-level domain without affecting the folder contents (lots of file types, so would like to avoid having to list each one as an exemption but if that's my only choice, so be it).
Got close with:
# Enable URL Rewriting
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(images|type|scripts)(/.*|$) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/robots.txt
RewriteCond %{REQUEST_URI} !images/.* [NC]
RewriteCond %{REQUEST_URI} !type/.* [NC]
RewriteCond %{REQUEST_URI} !scripts/.* [NC]
RewriteRule ^(.*)$ http://www\.domain\.com [L,QSA]
</IfModule>
Thanks to Christopher Brix and mootinator.
I need a general rule that maps every URL in the /beta subdirectory to the corresponding URL in the root; essentially I need to remove /beta from all URLs.
In case it makes any difference, the URLs are dynamically generated by WordPress.
Currently my .htaccess file is:
# 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
Can you tell me where to put the new lines?
Thank you!
Could you try this?
RewriteEngine On
RewriteRule ^beta/(.*)$ http://example.com/$1 [R=301,L]
Your question is not entirely clear, but I would bet that what you want is having a Wordpress installed in somedir/beta appear in yoursite.com/ instead of yoursite.com/beta/. The rules you pasted are in somedir/beta/.htaccess, and are the default Wordpress rules. You must leave those alone.
What you need for that is to put the following rules in the root directory, as in, somedir/.htaccess, after changing example.com to your own domain. Your webserver first reads this root .htaccess, and when it does, it will know to rewrite requests to /beta.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/beta/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /beta/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ beta/index.php [L]
</IfModule>
More info in the Codex:
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory