It's my first deployment on a server, and I have a white page. I tried several .htaccess, several dispositions, but it never worked.
Here is the /.htaccess file :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
Here is /www/.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
My arborescence looks like that :
.bash_logout
.bash_profile
.bashrc
.htaccess
.ovhconfig
Config/
Console/
Controller/
Lib/
Locale/
Model/
Plugin/
Test/
Vendor/
View/
app/
cakephp/
index.html
tmp/
www/
And in www, the content of app/webroot. I changed debug to 0, I tried several things, but I don't understand much of that. Does anyone know what's wrong or missing?
I finally found out : my index.php files weren't correct. I used the real root of the server, homz.800/, instead of just /, and it worked. To have css working properly, I've put the content of webroot, in the app folder, in www.
Here is a good practice to keep your app/ & lib/ folders outside the public box.
Main directory structure (/ is your root directory) :
/
.bash_history
.bash_logout
.bash_profile
.bashrc
.forward
.htaccess
cake_2.x.x/
app/
Config/
Console/
[...]
lib/
Cake/
[lib_subfolders]
[...]
www/
.htaccess
index.php
[js]
[css]
[images]
[...]
Here is the first .htaccess in root path /
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
The .htaccess in www/
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{HTTP_HOST} ^your_domain.com$
RewriteRule ^(.*) http://www.your_domain.com/$1 [QSA,L,R=301]
</IfModule>
Here is the index.php file inside www/ (important)
[...]
if (!defined('ROOT')) {
define('ROOT', DS . 'homez.800' . DS . 'your_domain');
}
[...]
if (!defined('APP_DIR')) {
define('APP_DIR', 'cake_2.x.x' . DS . 'app');
}
[...]
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'cake_2.x.x' . DS . 'lib');
Take care that your debug mode was set to 0 in app/Config/core.php
Configure::write('debug', 0);
No need of .htaccess and index.php inside app/ you can remove them.
Hope it will help!
Related
i created a react app using create-react-app , after finishing the development i runned ' yarn build ' then i uploaded the files in the build folder on the server using fileZilla ( i have a premium account on hostinger )
in my package.json i added the following line :
"homepage": "https://goinprod.com/",
my .htaccess file located in the public_html folder looks like this :
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW SSL_REDIRECT:goinprod.com
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?goinprod.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW SSL_REDIRECT:goinprod.com
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW UPGRADE_INSECURE_REQUESTS:goinprod.com
Header always set Content-Security-Policy: upgrade-insecure-requests
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW UPGRADE_INSECURE_REQUESTS:goinprod.com
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW SSL_REDIRECT:goinprod.com
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?goinprod.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# DO NOT REMOVE THIS LINE AND THE LINES BELLOW SSL_REDIRECT:goinprod.com
the home page looks fine but when i navigate in another page it show the following error
file structure on the server :
static ( folder )
asset-manifest.json
favicon.ico
index.html
logo.png
logo2.png
manifest.json
.htaccess.
precache-manifest.json
robots.txt
service-worker.js
my website link : https://goinprod.com/
it was a routing problem i just added the following code in the file .htaccess in public_html folder :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
I want to host my react app in a subdirectory on my shared hosting account. Ie in the directory domain.com/mydirectory/. But when I type domain.com/mydirectory/ in the search bar it opens the index of the directory & not the React App itself.
I have already created a build version for my app. Hence the index.html file is at the root of the directory with the static folder & all the other contents that where created during the react-build script.
How can I make it work properly ? How can I configure my .htaccess file or what fix should I consider ?
You can try to add a .htaccess file in your React directory with that source code into it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Just copy and paste following in your .htaccess
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
I have tried commenting this line present in congif/core.php,
// Configure::write('App.baseUrl', env('SCRIPT_NAME'));
But when I hit my url it gives me 404 error.
Make sure you are loading mod_rewrite correctly. You should see something like
#uncomment it by removing leading #
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Verify that your .htaccess files are actually in the right directories. Some operating systems treat files that start with ‘.’ as hidden and therefore won’t copy them.
#CAKEPHP root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
#Cakephp App directory .htacess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
#Cakephp webroot directory .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
URL_REWRITING
You may fix it with your web-sersver (.htaccess rules for apache, rules in configuration file for nginx).
I have an angular 2 app served on Angular 2. On the host, it is located at the document root and everything is working fine. I have an .htaccess file with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
Problem:
On my laptop, i have an Apache server (xampp) with document root as "
c:\users...\WebProjects
When i develop the site, i put the files in c:\users...\Projects\Projects1\dist
In this directory, i cannot get the website to work due to files/folders called not being in the root. ie Server is trying to load \css\app.css when it should be loading Projects1\dist\css\app.css
Can i write a specific .htaccess to be able to serve the app from that directory? (or something else without having to change the httpd.conf document root?)
thanks
you need to add the path in your .htaccess file and your index.html file like so:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your/path/here/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
In index.html, you need to update the base href aswell to reflect the path like so:
<base href="/your/path/here/">
And that should do the trick :)
Overview :
I would like to redirect the visitor on a default page(index.html) inside the directory structure to display when a directory is accessed using .htaccess file(as of now current directory index.html is loading).
But When I turn on $locationProvider.html5Mode(true) in my angular application getting below error.
Console Error :
Directory structure of Application :
public_html
--prod
--public
--app
--controllers
--directives
--services
--app.config.js
--index.html
--.htaccess
.htaccess
public_html => .htaccess :
DirectoryIndex prod/public/index.html
This .htaccess is used to redirect the visitors on a application page (prod/public/index.html) directly by using domain name, as of now when user visit the domain the current directory(public_html) index.html is loading.
public_html => prod => .htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /prod/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /prod/public/#/$1
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/prod/$1 [L,R=301]
</IfModule>
prod => public => index.html :
<base href="/prod/public/">
Everything working fine If i removed $locationProvider.html5Mode(true) from my app.config.js file.So, when I comment out the $locationProvider code, everything works fine in # mode. I can get to /#/abc, etc. without issue. As soon as I put the $locationProvider parts back in, nothing happen.
Related issues on Stack Overflow with no success :
$locationProvider.html5Mode(true) issues
Angular html5 mode not working in apache
Inside public_html => .htaccess have this rule instead:
DirectoryIndex index.html
RewriteEngine On
RewriteRule ^/?$ prod/public/index.html [L]
then public_html => prod => .htaccess should have this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ public/index.html [L]