My query is as following:
On my server, I have multiple codeigniter apps in one folder and 1 subdomain pointing to that folder
Please see the following structure:
eApps (Main Folder)
index.php (used to redirect to Main App) File
Main App (Used for redirecting to other apps) (Sub Folder)
Timekeeping App (Sub Folder)
Activity Delivery App (Sub Folder)
.....so on (15 Apps in total) (Sub Folders)
The main app redirects to other apps by having a common session. This is working perfectly fine on the local server
But on the live server (1and1.co.uk), it has the following problems:
This is due to improper (htaccess) I think:
I don't know what htaccess files to keep in the main folder and what in each folders in order for this to work properly
Sometimes it gives 404 page not found error as well
This is the .htaccess in the main folder:
I also have many app in one folder in my server and for all .htaccess file I use the following code which works fine for me.
Try replacing the following code in your .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|fevicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
Related
I currently new for deploying a project files to the godaddy hosting sites, so before i post this, I read some related question created already here in stackoverflow, I just confuse because there cpanel has public_html folder and my panel has no public html. so right now I experience
HTTP Error 404. The requested resource is not found.
The things only I do is to move the laravel files in the httpdocs.
My CPanel : Plesk Onyx 17.8.11
For the folder structure:
So Inside of httpdocs are all of my laravel files
Website shows like this..
Hope someone help me for this problem.
I think the reason your folder structure is like this is that your GoDaddy Hosting is a Windows Shared Hosting.
What to basically need to do is create a folder for your app on the home directory and then on the httpdocs, put the public folder from your app.
GoDaddy Plesk Folder List:
cgi-bin
error_docs
httpdocs
logs
<your laravel app folder minus the "Public" folder>
Inside the httpdocs folder:
App_Data
.user.ini
Default.aspx
web.config
<+ contents of your Public folder>
Once this is complete, you will need to edit a few files:
From Public Folder: index.php
Find:
require __DIR__.'/../vendor/autoload.php';
Change to:
require __DIR__.'/../<laravel app folder>/vendor/autoload.php';
Next Find:
$app = require_once __DIR__.'/../bootstrap/app.php';
Change to:
$app = require_once __DIR__.'/../<laravel app folder>/bootstrap/app.php';
After this, make sure the .env file is properly configured and all the tables from your local database is mirrored in you server database.
Also, if you have open_dir problems, you can disable it on the PHP Settings from Plesk but I am not sure what are the issues this will cause in the long run.
Well, there are two ways...
1st in cpanel search for "Installatron Applications Installer" or somekind of app installer :)
In installatron app installer screen on right top find "Applications Browser" from there search for Laravel and install it by choosing your domain(If you have more than one domain)
After installation copy and replace your local files with the remote files.
2nd second way, .zip your local laravel folder. And upload your files to your server, and then extract the files.
NOW FROM HERE IT'S THE SAME FOR BOTH WAYS->
"public" directory in laravel project will be in the root of your remote server(root folder for your domain, If you have addon domains for ex. public_html/example.com then "public" folder should be in that example.com)
make another folder and put all other laravel files and folders in that folder.
open and edit /public/index.php
change these two lines->
require DIR.'/../vendor/autoload.php';
app = require_once DIR.'/../bootstrap/app.php';
to reflect the file structure in your server.
For ex. if "public" folder is in the same directory with "vendor" and "bootstrap" remove /..
Edit your .env file pay attention to database credentials.
PS: do not change database host address it should remain same.
AND FINALLY the .htaccess files
you need to have two .htaccess files
one in "public" directory content like this->
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Second .htaccess file will be in the root folder of the domain with content->
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
ONE PROBLEM YOU MIGHT COME ACCROSS if php version problem stating that composer dependencies version is php7.xx bla bla
If this happens go to cpanel again and search for "Select PHP Version"
From there change your current PHP version to suit with the PHP version you get in the error. And you need to click "Set as current"!
That's it :)
I have read the doc from Yii2 official website to deploy yii2 into share host from this : http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html, and about discussion on this : stackoverflow.
So, I decide to use sftp to upload the yii2 folder.
And this is the list of directory in my share host.
access-logs
etc
logs
public_ftp
public_html
ssl
www (this is a link folder to public_html)
You know, because the share host can hold on domains untill 5 domains,
is it possible to upload yii2basic folder into public_html folder ?
So the result like this :
access-logs
etc
logs
public_ftp
public_html
-basic
- bunch of yii folders here
ssl
www (this is a link folder to public_html)
Because now, if I want to access my web, I have to write like this : mydomain.com/basic/public_html/index.php
I need like this :
mydomain.com/index.php
Please guide me.
Yes you can upload it inside the public_html folder but the only problem that I have been facing nowadays with yii2 basic app is the pretty URLs, you can clone or upload entire contents inside the public_html folder, what I did is as follows only the difference is I have a web folder instead of www
directory structure
public_html
assets
commands
config
controller
mail
migrations
models
runtime
tests
vendor
views
web
public_html/.htaccess
<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ web/$1 [L]
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php
</IfModule>
public_html/web/.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
this works but in the URL it shows /web/index.php?r=site/index and as soon as I turn the prettyUrl on in the config file urlManager it would only show default index page and every link I try to open ends up on the home page view although the URL in the address bar is correct and urlManager parses the rules correctly, this is as far as I have gone.
If you don't mind bunch of Yii 2 folders in your root folder just place all basic template folders (except web) and files in the root folder. Then place the content of web folder in the public_html folder.
It should be something like:
access-logs
assets
commands
config
controllers
etc
logs
mail
models
public_ftp
public_html
// here should be the content of web folder of Yii 2 basic app
runtime
ssl
test
views
widgets
I have a big problem that causes my whole web root to shut down (505 Internal Error) where every domain is affected, even if the htaccess file is only in one directory. My file structure is organized this way, so every domain is a seperate folder:
web root
-- [domainA]
(domainA files like the .htaccess file)
-- [domainB]
-- [domainC]
(web root files)
I want to implement my routing system and everything works fine on my localhost with this .htaccess code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
However, I'm testing for hours to make my routing work on my remote server with the same .htaccess code. I uploaded the file and it also works when I'm at the main directory like www.domainA.com.
BUT every link I'm clicking on my website like www.domainA.com/signup leads to an 505 Internal Server Error. The whole domain isn't even responding for a long time. I have to delete the .htaccess file from my remote server and maybe after 15-30 minutes it's reachable again. That also makes this problem so difficult to debug. Also my whole web root seems to be affected since all other domains aren't reachable, too (even if the .htaccess file is only located in the seperate domain folder like in [domainA]).
Then I tried to apply my rule only on a specific user agent named fake-user:
RewriteCond %{HTTP_USER_AGENT} ^fake-user$
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
This way it surprisingly works like on localhost and I don't get why. Obviously I don't want to limit my audience to user agents named fake-user to interact with my website. So currently all other users would "crash" my website. I hope to get some explanations what could cause this and how to fix this problem to make it work like on my localhost for all users?
Sounds like it could be recursion, try replacing your rule with this:
RewriteRule ^(?!index\.php$). index.php [NS,L]
which only rewrites when it's different.
I currently use laravel 5 for web development. And my goal is to upload the website which I made in laravel to a shared host.
But if I upload my files to the public_html folder, I'll have to navigate to mywebsite.com/public/mypage to access a route mypage. Which is not what I want.
I would have just changed the the name of public folder to public_html and then shifted all other folders to the root directory and changed some laravel config options, but that would have made my root directory unclean. So think I would have to use .htaccess for what I want. I am not familiar in using .htaccess, so how would I do this:
If the user enters mywebsite.com/mypage in the browser he gets to see the page mywebsite.com/public/mypage in the browser, but the url in the browser stays the same.
Thanks, in advance.
I also got the same problem when hosting my website in shared hosting godaddy.
I also used laravel5 frameowork and launched the site http://www.hahafunnyjokes.com
Edit the .htaccess file in the root folder where your public_html pointing
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.examplecom/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Thats it, I got my site up and running.
Replace example.com with your website name
I want to create a copy of my currently running codeigniter website, say http://www.example.com and place the copy in a new subdomain "beta", say http://beta.example.com for test purposes and site modifications, so that the live site doesnt gets unmanaged due to the modifications.
So its about making a replica of website for test purposes and modifications under beta subdomain. How should I do it?
This is the file-structure I am having in beta subdomain
Use this htaccess file in ur main directory
for url like www.website.com
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php/$0 [PT,L]
for your testing link like www.website/test use the following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /test/index.php/$0 [PT,L]
First use your cpanel to add a new subdomain: http://documentation.cpanel.net/display/ALD/Subdomains . While adding the subdomain you will have to enter its document root path.
If your website uses a database, then you need to create a new database using MySQL Databases option in cPanel. After creating a database and assigning a user to it, open phpMyAdmin, go to the original database, go to Operations tab in phpMyAdmin and copy that database to the new database you created.
Open File Manager and copy all the files related to your main website. Paste them in the subdomain's document root.
If your website uses a database, you will have to finally modify the database connection parameters in your site code. You can find the location of config easily through a grep command:
grep -r "mysql" /public_html/subdomain/
Now when you open http://beta.example.com you should see the replica website.