I'm trying to figure out how to set up a domain and subdomain to work on a shared hosting account. It is a Laravel 5.1 application.
My access file is
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^ index.php [L]
I just purchased another domain and added it on, but I get a 500 error. I renamed the access file and then it worked. So it has something to do with the access file. Essentially I want two separate domains with and I'm wanting two separate laravel applications, one for each.
I'm not familiar with atacceess.
Maybe, you get a redirect loop, because the rule isn't protected by a condition. Although the default htaccess of Laravel should already contain them.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Olaf Dietsche's answer does work for me.
Here is another thing I came upon a website that also worked just before I saw his post. I guess I was reading that this would send a 404 to that directory.
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^ index.php [L]
RewriteCond %{HTTP_HOST} ^(www.)?main-topdomain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/subdomain-folder/(.*)$
RewriteRule ^(.*)$ - [L,R=404]
So along with this comes another question if anyone is in my boat. I have my subdirectory inside of my root directory.***
dlaugh.com/public_html
laravel folders and access**
inluding
app
bootstrap
config
database
etc...
but also I have my sub folder
app
bootstrap
config
database
etc...
**mysubdomain in that folder**
Is it better practice to put
-main_domain_folder and
-subdomain_folder
in public_html
and then the
/app
/config
/database
would be in the main_domain_folder rather than passing the subdomain through the main domain?
I am working on my own PHP Framework. I am currently developing it on localhost and everything related to project is in subfolder called RuddyPhpFramework, so the path look like this:
localhost/RuddyPhpFramework/
In that folder, I do have index.php, the init point of whole Framework. I am currently working on my own router, but I have a two problems. First, in Apache's htaccess file a have this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) RuddyPhpFramework/index.php [L]
So whenever someone acces a page like this:
localhost/RuddyPhpFramework/something/smtelse/
The index.php will init the application and echo a path for me, which is:
[path] => /RuddyPhpFramework/something/smtelse/
But that is not excatly what I want. What I want is to get a relative path to subfolder (I don't know if I am explaining this correctly), for example:
[path] => /something/smtelse/
And another problem is that I want to setup the htacces so the last line would look something like this:
RewriteRule (.*) index.php [L]
So it will go for the index.php in the folder where is the htaccess file (/RuddyPhpFramework/index.php) and not /index.php, without specifying the foler, because if someone else will be using the framework, he might have it in a folder with different name.
first please stop we have enouth frameworks already. Now regarding your question. Your project is in localhost/RuddyPhpFramework so htaccess read url from first / so he skips localhost because it's domain and taiks uri witch starts from /
so you project setup is incorrect. what you could try not shure 100%:
RewriteEngine On
RewriteBase /RuddyPhpFramework/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php [L]
please try it. and say did it helped.
I have hosted my new website here http://cvspforcomval.site90.net/ which is a free hosting site. The problem is that I can't see the pictures in my slide, and when I enter to the navigation links I get an error.
I have changed the default webroot/index.php to:
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'a3503999');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
and my directory goes like this
/root/
public_html/ <---webroot
app/
lib/
I'm just wondering if using the free hosting site affects the error. Or I just missed something out.
<---EDITED Added below--->
In my shared hosting site. I have setup folder in this way
/app
/public_html <---webrooot
/lib
I have the default htaccess in my public_html which is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
My suspicious is that i need to change my .htaccess. I haven't solved it yet
i am getting page not found error which is due to the anchors. You are not using proper ctp links.You have to create the anchors as
$this->Html->link(__'My Page',array('controller'=>'Home','action'=>'name_of_action'));
I have a production copy and a test copy of my website on bluehost. Each website is in it's own directory in public_html folder, one named prod another named test. According to bluehost knoweldge base here: https://my.bluehost.com/cgi/help/347 you setup an htaccess file to rewrite requests coming into the public_html folder to my prod folder. This works pretty well thus far. Something I noticed recently though was with these rewrite settings that if you attempt to load a website file from another directory inside the main website folder e.g. /prod/testfolder without a forward slash on the end it will redirect you to www.mysite.com/prod/testfolder/ instead of staying on www.mysite.com/testfolder. This condition does not happen if you specify the extra forward slash like so.... www.mysite.com/testfolder/
Here is my rewrite rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/prod/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /prod/$1
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ prod/index.php [L]
I'm not an expert when it comes to rewriting urls using htaccess however I suspect the first chunk of rewrite rules is the cause of this. BTW an example of why this makes a difference is that I setup a blog on this site and if you attempt to visit the blog at www.mysite.com/blog it redirects to www.mysite.com/prod/blog/ which defeats the purpose of using htaccess to mask the prod folder in the first place. Can anyone tell me how I should go about fixing this and maybe explain why it's happening? Thank you!
I have never used CodeIgniter before, let alone ANY php framework and I thought I would give it a try. Everything is going fine except I cannot seem to remove the index.php from the URL and still access my pages.
I have never used the MVC structure so I am learning as I go, so forgive me if I'm doing this wrong.
I am trying to access a view I created called 'about_page.php' by simply typing in localhost/ci/about but currently I can only access it by using localhost/ci/index.php/about
The controller for the page is: /application/controllers/about.php
The Model for the page is: /application/models/about_model.php
And the View for the page is: /application/views/about_page.php
I have searched for a solution to this issue, but haven't been able to find one. Here is where I have already searched:
CodeIgniter - removing index.php
Codeigniter - how to remove the index.php from url?
http://www.farinspace.com/codeigniter-htaccess-file/
CodeIgniter comes with a .htaccess file in the 'application' folder which contains only Allow Deny From All. So I created a new .htaccess file in the root directory, http://localhost/ci/.htaccess and added this code to it:
RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
When the .htaccess file is in the root directory I get a 500 Internal Server Error. When I copy the exact same file into the applications folder the 500 error goes away, but I still cannot access the about page by using localhost/ci/about
I have already changed $config['index_page'] = 'index.php'; to $config['index_page'] = ''; AND I tried changing $config['uri_protocol'] = 'AUTO'; to $config['uri_protocol'] = 'REQUEST_URI'; but I am still getting the Internal Server Error.
I went into the httpd.conf file and uncommented the mod_rewrite.so module so I know mod_rewrite is active.
Does anyone have any ideas why this isn't working or how I can get this work? I know there are alot of questions on StackOverflow on this subject but I couldn't find one that answered my question.
Am I doing this right? Should I even be able to access the about page by visiting localhost/ci/about or do I have to create an 'about' directory in the 'application' directory?
There are 3 steps to remove index.php.
Make below changes in application/config.php file
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Make .htaccess file in your root directory using below code
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Enable the rewrite engine (if not already enabled)
i. First, initiate it with the following command:
a2enmod rewrite
ii. Edit the file /etc/apache2/sites-enabled/000-default
Change all AllowOverride None to AllowOverride All.
Note: In latest version you need to change in /etc/apache2/apache2.conf file
iii. Restart your server with the following command:
sudo /etc/init.d/apache2 restart
Your .htaccess is slightly off. Look at mine:
RewriteEngine On
RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /codeigniter/index.php?/$1 [L]
Notice "codeigniter" in two places.
after that, in your config:
base_url = "http://localhost/codeigniter"
index = ""
Change codeigniter to "ci" whereever appropriate
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dmizone_bkp
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /dmizone_bkp/index.php?/$1 [L]
</IfModule>
This works for me
Move your .htaccess file to root folder (locate before application folder in my case)
RewriteEngine on
RewriteBase /yourProjectFolder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Mine config.php looks like this (application/config/config.php)
$config['base_url'] = "";
$config['index_page'] = "index.php";
$config['uri_protocol'] = "AUTO";
Let me know if its working for you guys too ! Cheers !
I am using something like this - codeigniter-htaccess-file, its a good article to begin with.
leave the .htaccess file in CI root dir
make sure that mod_rewrite is on
check for typos (ie. controller file/class name)
in /application/config/config.php set $config['index_page'] = "";
in /application/config/routes.php set your default controller $route['default_controller']="home";
If you are running clean installation of CI (2.1.3) there isn't really much that could be wrong.
2 config files
controller
.htaccess
mod_rewrite
read
Codeigniter .htaccess
redirect-index-php-in-codeigniter
For those users of wamp server, follow the first 2 steps of #Raul Chipad's solution then:
Click the wamp icon (normally in green), go to "Apache" > "Apache modules" > "rewrite_module". The "rewrite_module" should be ticked! And then it's the way to go!
if not working
$config['uri_protocol'] = 'AUTO';
change it to
$config['uri_protocol'] = 'PATH_INFO';
if not working change it to
$config['uri_protocol'] = 'QUERY_STRING';
if use this
$config['uri_protocol'] = 'ORIG_PATH_INFO';
with redirect or header location to url not in htaccess will not work you must add the url in htaccess to work
I had similar issue on Linux Ubuntu 14.
After constant 403 error messages in the browser and reading all answers here I could not figure out what was wrong.
Then I have reached for apache's error log, and finally got a hint that was a bit unexpected but perfectly logical.
the codeIgniter main folder had no X permission on folder rendering everything else unreadable by web server.
chmod ugo+x yourCodeIgniterFolder
fixed first problem. Killed 403 errors.
But then I started getting error 500.
Culprit was a wrong settings line in .htaccess
Then I started getting php errors.
Culprit was same problem as main folder no X flag for 'others' permission for inner folders in application and system folders.
My two cents for this question: READ Apache Error.log.
But, also be aware of security issues. CodeIgniter suggests moving application and system folder out of web space therefore changing permissions shall be taken with a great care if these folders remain in web space.
Another thing worth mentioning here is that I have unzipped downloaded CodeIgniter archive directly to the web space. Folder permissions are likely created straight from the archive. As given they are secure, but folder access issue (on unix like systems) is not mentioned in CodeIgniter manual https://codeigniter.com/user_guide/installation/index.html and perhaps it shall be mentioned there with guidelines on how to relax security for CodeIgniter to work while keeping security tight for the production system (some security hints are already there in the manual as mentioned beforehand).
Just add this in the .htaccess file:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
By default the below sits in the application folder, move it like suggested into the root dir.
leave the .htaccess file in CI root dir
Open the application/config/config.php file and make the changes given below,
set your base url by replacing the value of $config['base_url'], as
$config['base_url'] = 'http://localhost/YOUR_PROJECT_DIR_NAME';
make the $config['index_page'] configuration to empty as $config['index_page'] = '';
Create new .htaccess file in project root folder and use the given settings,
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|assets|images|js|css|uploads|favicon.png|favicon.ico|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Restart the server, open the project and you'll be good to go.