I Have A shared host and i have made a laravel project and when i upload it to the host
i made a htaccess file to redirect all requests to publc/index.php
and it works very well and laravel project work good
when i create a sub domain and but some files in subdomain's folder and try to access it
i got a 500 Internal Server Error
when i contaced the support they told me that this error because the .htaccess that i made
i need help to solve this problem
this is the structure of my public_html folder
-public_html
|-laravelproject
|- Laravel Projct Files
|-subdomain
|-index.php
|-.htaccess
.htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^laravelproject/public
RewriteRule ^(.*)$ laravelproject/public/$1 [L]
</IfModule>
Since subdomain is other installation i think you should add
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^laravelproject/public
RewriteRule ^(.*)$ laravelproject/public/$1 [L]
RewriteCond %{REQUEST_URI} !^subdomain/public
RewriteRule ^(.*)$ subdomain/public/$1 [L]
</IfModule>
But im no .htaccess expert, hope it works!...
Related
I am trying to deploy my Laravel 8 app to a folder in CPANEL (first time I've deployed Laravel). I have searched the forum and made changes as the many posts direct. I am getting 404 errors across all pages apart from the homepage and login and register pages. This is a common error but I cant find a solution. Dont shoot me.
1.All files uploaded to url/laravel/blog
Public folder moved outside and renamed public_html
The /laravel folder now has two directories /blog and /public_html
index.php in the public_html folder updated:
require DIR.'/../blog/vendor/autoload.php';
$app = require_once DIR.'/../blog/bootstrap/app.php';
New .htaccess file added to the root of the public_html and set to chmod 755 (detailed below)
Renamed the cache folder in the /bootstrap folder so that new cache is created (I hope)
Database is linked within the .env file
I am out of ideas, I have created a test html file in the public folder and I can see this in the browser when I navigate to it. I am learning and any help will be appreciated.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I needed to point the subdomain/add-on domain to the public folder. No need to move anything or change Htaccess etc.... Credit to https://stackoverflow.com/users/2325620/james-clark-developer
Try this in your .htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>
I'm trying to publish my first Symfony Project in production, but I'm very worried about security, I have taken the following measures:
1) First: Delete on /var these directories: cache, logs and sessions
2) Second: Changed of default name for cookie session (client side: symfony)
3) Trhee: Creating a .htaccess in root directory of application
My problem is about the .htaccess. The goal is dennied access to others directories of application like: /app, /src, /test, /var, /vendor.
I'll write the follow rules in .htaccess and puted it in root directory of my app: myDevelopedApp/.htaccess.
.htaccess
#Checking if module is avalaible
<IfModule mod_rewrite.c>
#Using the rewrite engine
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
#Rewrite rule to redirect the request
RewriteRule ^(.*)$ web/$1 [QSA,L]
<IfModule>
The problem it's not working, I can not access to web folder when I write the rules. Apache hides the application myDevelopedApp when I try to access it by browser
What I'm wrong?
Any other recommendation to improve security in production enviroment is welcome, thanks so much.
If your are really concerned about security you should follow the Symfony best practices. That means that only the /web folder should be accessible in the vhost.
Moreover if you initialized your project with a standard edition you should already have .htaccess files in the app/ src/ folders.
htaccess file code
.htaccess
#Checking if module is avalaible
#Using the rewrite engine
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
#Rewrite rule to redirect the request
RewriteRule ^(.*)$ web/$1 [QSA,L]
and this code too on your .htaccess file
<pre>
.htaccess
#Checking if module is avalaible
<IfModule mod_rewrite.c>
#Using the rewrite engine
RewriteEngine On
RewriteBase /folder/ /*location address if localhost localhost/project */
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#Rewrite rule to redirect the request
RewriteRule ^(.*)$ web/$1 [QSA,L]
<IfModule>
</pre>
RewriteBase solve this problem
I want to setup cakephp 3.x solution inside WP website.
On my bluehost server, I have directory structure in public_html is as follows:
I want to access stagetribescrm directory and that directory contains Cakephp 3.x file structure.
.
Code Inside of public_html/stagetribescrm/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /stagetribescrm/
# RewriteRule ^$ webroot/ [L]
# RewriteRule (.*) webroot/$1 [L]
</IfModule>
Code Inside of public_html/stagetribescrm/webroot/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And the problem with this code is that it couldn't load css and js files inside webroot folder's file.
Thanks.
Please check for rewrite module is turn on or not in bluehost server than
follow below link:
http://www.abhinavsood.com/install-cakephp-in-subdirectory-of-wordpress/
I have just uploaded all file of my test website to 000webhost.com domain.
My site is farazphptest.comxa.com
I was working on Codeigniter before uploading the site. All of my controllers are working fine on my localhost, but after uploading the site on server when i try to access a controller say farazphptest.comxa.com/welcome where "Welcome" is my webpage/controller, it does not work and opens "error404.000webhost.com/?" All of my controller including "welcome" are working fine on localhost, but after uploading website on domain only the home page loads perfectly.
This is the 1st time i have put a site on web, do tell me if i am missing out some tricks. I have just simply copied my file on web as stated. Thanks
Here is my .htaccess file used in both for localhost and on server.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /faraztest
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /faraztest/index.php
</IfModule>
An alternative solution is to create sub-domain on 000webhost.com with project name , and call the project from sub domain url Directly, it will be like this :
From Cpanel got to Subdomains
Create new subdomain with project folder name. ex : test.farazphptest.comxa.com
Overwrite the created subdomain folder with your project folder. ex : test
Edit your .htaccess in your main uploaded project folder to be like this :
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
now you can call your project directly from the new subdomain url.
ex : http://test.farazphptest.comxa.com
Following solved my problem
My .htccess file is
# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
and it worked like charm!
I tried to make Laravel works on my environment (MAMP) but i'm stuck in this situation.
The index.php file of Laravel is into a subfolder called "public", so if I want to test my application I need to access it with this url http://localhost/laravel/public/
but I want access with http://localhost/laravel
I tried to set an htaccess with this rows but it doesn't work:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ public/$1
</IfModule>
I'm not sure that this htaccess can resolves this situation, I get a 404 generated by Lavarel.
You need to create a virtualhost. Dayle Ress covers this in the first chapter in his Laravel book: https://web.archive.org/web/20121013083457/http://daylerees.com/2012/03/25/laravel-getting-started/
Put .htacess file in root with code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
public is actually the part that should be your document root.