I have the following shared hosting file structure using a codeigniter project:
myTLD.com/sites/mysite
mysite contains: application, system , index.php ... ( standard CI2 setup )
myTLD.com/public_html - contains : index.php
I have symlinked myTLD.com/public_html/index.php to myTLD.com/sites/mysite/index.php
Unfortunately I am getting:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
I have set it up this way to avoid placing the actual site in the document root for security purposes . I don't want to change mysite/index.php because I want to keep the entire project in its mysite directory where it can easily be revised etc.
The application and mysite/ folder are set to 755 so I don't think this is a permission problem .
My myTLD.com/public_html/.htaccess folder directs all requests to index.php:
RewriteEngine On
RewriteRule ^(.*)$ index.php
Can someone advise me on an approach to sending requests through to the codeigniter index file without causing this error?
Thank you
You can try following way
1) Remove the symlink
2) Use this in htaccess at myTLD.com/public_html/.htaccess
RewriteEngine on
RewriteRule ^(.*)$ myTLD.com/sites/mysite/index.php?/$1 [L]
Use absolute system path if you are aware of it.
Related
I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....
I am installing Yii2 on a shared hosting environment,Apache, (Godaddy),
here is what I did as per the docs:
Renamed web folder to www
copied all the folders, now the directory structure looks like this:
public_html\
assets
commands
config
controllers
model
modules
views
www\index.php
.htaccess (this is both in public_html and www)
but when I access my domain, I get the following error:
You don't have permission to access / on this server. Additionally, a
404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
Here are the contents of my .htaccess which I have copied in both public_html and www.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
is the htaccess creating problem? Is index.php not being run from the right folder? What else should I look for? any help is much appreciated.
Update:
The actual problem with the above error was that It was a Permissions issue.
Set the permissions from 644 to 755, and now the system is accessible.
BUT
the to access index.php I still need to navigate to it manually by typing in the url : www.example.com/www/index.php
UPDATE
As I don't have prettyurl's enabled, just to make it work, I deleted all the contents of the .htaccess, then I copied the contents of basic folder in the home folder (for future visitors it should be like home/your_user _name
CAVEAT EMPTOR
I know almost nothing about .htaccess. Also my this project is just for learning, this solution may not be useful in production settings.
Question is still open for expert advice on best practices in such scenario.
You need to move your domain pointer to www instead of htdocs, its probably somewhere under domain -> root folder. Your .htaccess looks fine.
I want to host my Laravel 4 project on free webhosting. To work, the hosting root dir must point to the "public" folder of my project where is taking place the .htaccess file. I did not succeed with finding free hosting which allows changing the root dir so I tried to place another .htaccess file in the main project dir which redirects to the public folder. Then the landing page opens but non of the routes in routes.php works. So my question is:
Is it possible to put the .htaccess file from "public" to the main dir and the application to work properly ?
Hope my question was clear.
Yes, you can do that from create a .htaccess file in your laravel root directory.and put below code in that file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It should be redirected easily.
Another way to remove public folder
for more reference click here....
I have the following directory structure of Codeigniter Folder. You can see that I have put all my assets in the assets folder at the root of the application.
Base URL is defined as
$config['base_url'] = 'http://kamran.dev/Codeigniter/application/';
I tried modify it to
$config['base_url'] = 'http://kamran.dev/Codeigniter/';
but that didn't work either.
Can anyone please have a look and tell me what I'm doing wrong here?
P.S. Then I removed the .htaccess file from the application folder that contains
Deny From All
And this worked for me. But that doesn't seem like a good idea.
You have multiple options here. The easiest one is to move the assets folder to the same level as the application so that your directory structure is:
application
system
assets
css
img
js
Because the assets folder is not in a folder with the .htaccess with Deny From All it won't be blocked by your web server.
Alternatively you can add an .htaccess file in the assets folder with the following rule:
# /assets/.htaccess
Allow from all
I haven't tested this but I think it should work.
Another option is to change the .htaccess and put an exception on the assets folder but it's a very bad idea (with security implications) to remove the Deny From All without writing alternate rules to lock all folders that shouldn't be accessible.
Also, set your base_url to the folder containing application, system and assets directories (this folder contains Codeigniter's bootstrap/front controller index.php).
Additionally, I would advise you to echo your urls using the base_url() function:
base_url("assets/css/bootstrap.min.css");
OR to call a controller/route
base_url("controller/method");
The base_url function takes into account the value of $config['index_page'] as well as the necessary leading/trailing slashes.
Change your base_url to the following:
echo base_url("assets/css/file-name-here.css");
You want to pass the URL string to the base_url function. This way, you can change $config['base_url'] to whatever you want and it will append the string to that URL properly.
As an addition to the answer of grim. If you have your rewrite engine on you should have the following in your root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
I have a php websites hosted on a server. I use CPanel to manage it. public_html has lets say following directory structure
public_html
- dir1
- dir2
- dir3
- ....other files.....
- website2home
Now I am trying to make website2home as the base directory of my website, but files inside website2home use some files from public_html folder and some files from within itself.
THE PROBLEM
When I assign a domain name to website2home, It does not reads the files from public_html folder (in fact, public_html folder is not visible) and shows some php warnings and some 404 not found errors. But lets say the domain name for original website is www.aaa.com, then if I access website2home by using www.aaa.com/website2home all works fine.
So My Question...
Is there any way to set the base directory, so that my website2home fetches all files and correct files without replacing hundreds of filepaths in php code?
Please answer considering that I don't want to modify source files of website.
I believe you are looking for some kind of .htaccess configuration. For instance, you may set your website2home folder as base folder for your www.aaa.com domain and then redirect some file access to other folders using .htaccess, something like this..
RewriteEngine on
RewriteRule captcha.jpg ../captcha.jpg
RewriteRule \.pdf$ ../pdf_files/$1
Have a look to mod_rewrite documentation
Edit: If, for some reason, the ../ redirection doesn't work, you always can redirect all your files to a pseudo-index PHP page. For instance:
RewriteEngine on
RewriteRule captcha.jpg my_index.php?access=../captcha.jpg
RewriteRule \.pdf$ my_index.php?access=../pdf_files/$1
And then, in your index PHP page you can simply load your PHP files in other folder:
require "../pdf_files/$requested";