问题
I"m trying to set up a laravel project as the main page for this cpanel, I'll be blurring out the website name and such for privacy reasons. I've made a redirect to the directory like this
When I click on the directory link, I get sent to the project but get these errors
Refused to apply style from 'http://page_example.com/css/app.css?id=4513b702e5714c4239c0' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
If I try and go into the website just the page without the /ex_server/public
I get redirected to just page_example.com/ex_server
without the /public
and I get a 403 forbidden.
I don't think the redirect is even working, because in the index.php file in the public_html file I have this, If I leave only the first two default blocks of code then I get redirected to the default a2hosting page, but if I comment that first stuff out and only leave the manual redirect then I do get redirected to that page.
<?
if (file_exists('./index.html')) {
rename('./index.php', './a2-default-index.php');
header('refresh:1');
}
$ch = curl_init('http://default.a2hosting.com/');
curl_exec($ch); curl_close($ch);
?>
<?php
header("Location: http://www.page_example.com/ex_server");
die();
?>
How can I fix these errors and get the redirect working correctly?
回答1:
You can try this add this file
.htaccess file to public_html folder
RewriteEngine on
# for example.com rewrite landing page to subdirectory/index.php
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^/?$ subdirectory/index.php[L]
# for example.com rewrite all other URIs to subdirectory/uri
# (?!subdirectory/) is a negative lookahead that stops rewrite then uri
# already starts with /subdirectory/
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(?!subdirectory/)(.+)$ subdirectory/$1 [L,NC]
Change subdirectory to home and example to your domain name.
来源:https://stackoverflow.com/questions/58864516/setting-up-a-laravel-project-on-a-server-with-cpanel