local assets(css/js) not found when using apache virtual host - php

I've added 127.0.0.1 my.pro to my hosts file
and add below code to httpd-vhosts
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/ci4/public"
ServerName my.pro
ErrorLog "logs/myproject-error_log"
CustomLog "logs/myproject-access_log" common
</VirtualHost>
the problem is i can't reffer to my assetes. assetes and project index page are in defferent directories.
-ci4
--public
---index.php
--assets
---css
C:/xampp/htdocs/ci4/public is project root and i locate assetes in C:/xampp/htdocs/ci4/assetes .
when I try to load a CSS file with this resource http://my.pro/assets/css/style.css it shows 404 error.
I know apache tries to load file from C:/xampp/htdocs/ci4/public/assets/css/style.css which doesn't exist.
but I have no idea how to fix it!

Related

How to Fix 404 Error After Fresh Magento 2 Installation

I'm trying to install Magento 2 to run on my local machine. I've followed the tutorial here: https://javapocalypse.medium.com/install-magento-2-4-on-windows-10-2021-a0c433e4ffc4, but when I go to localhost/magento I get a 404 error and am not sure how to fix it. I've tried replacing the .htaccess file in the root directory with the .htaccess file from /pub, and I've also tried moving index.php from /pub to the root directory, but have had no luck.
Any guidance would be appreciated.
Check if you did below steps
Add entry in host files C:\xampp\apache\conf\extra\vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/magento/pub"
ServerName localhost/magento
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
Add entry in hosts file
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost/magento
I suggest you to use a different url like dev.magento.com instead of localhost/magento.

Creating new symfony project on localhost

Hello I'm trying to run project using newest symfony on my localhost.
What i already did:
I added this to my vhosts file in Xampp.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "F:\Programy\XAMP\htdocs\Anka\web"
ServerName Anka
DirectoryIndex app_dev.php
ErrorLog "logs/vark.local-error.log"
CustomLog "logs/vark.local-access.log" common
</VirtualHost>
I added this in my hosts file in Windows\System32...
127.0.0.1 Anka
This is what i see after typing
anka\
In my browser.
My localhost website
And when i click on web i see this:
web
Can somebody help me what else i should do to see normal Symfony index page?
Try http://anka/app_dev.php or http://anka/web/app_dev.php
Also You can Change the directory to this one with the application and run:
php bin/console server:run
Then access http://localhost:8000/ in your browser
Like this:
https://symfony.com/doc/current/setup.html#running-the-symfony-application
First of all - ServerName value is case-sensitive, to Apache is not really recognizing request as this VirtualHost and you're getting listing of root directory.
Use http://Anka url, or change ServerName Anka to ServerName anka and 127.0.0.1 Anka into 127.0.0.1 anka.
Next thing is that you have some errors in your code and PHP cannot find AnkaBundle\AnkaBundle class. You're probably missing an autoloader, but that's only my guess. Not enough information to be sure.

Creating Virtual Host on apache not loading styles from root directory

I am new to VPS hosting.... and giving a try to digital ocean Linux VPS. I need to point 2 domains to my PHP app.
This is how my Virtual Host looks like inside /etc/apache2/sites-available
<VirtualHost *:80>
ServerAdmin root#domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
However... I am not able to load my styling and access any files or directories that is in var/www/html directory. How can I enable the permissions for my domains to access these resources.
Similarly my second Virtual host for another domain
DocumentRoot /var/www/html/app/login.php
Everything seems working while I am accessing the site using the IP...However... after setting up virtual host... the content is loading but can not access css and js... in the current root directory.
I am not sure what I need to do to set up my domains as expected.
I am using ../ notation to point my previous directory. There is no error with the site that is showing...just not loading CSS. Also I have the APIs in the root directory.... inside API folder.... that is not accessible while I am pointing them ../../API/v1/create_user.php

MAMP virtualHost does not open file under specified directory

I am trying to set up VirtualHost on my MAMP. I Edited the http-vhost.conf file like so:
<VirtualHost *:8888>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot “/Applications/MAMP/htdocs/factoryPattern/”
ServerName factory
</VirtualHost>
I theory I would expect to type in my browser factory and index file under the fiven directory would open. Instead what I get when I type in Factory in my browser factoryPattern folder that I have to click and then i need to clinc index.php file to view the file content.
I would like if this would of happen automatically by typing Factory...
What am I doing wrong...?

Wordpress site returning 404 error when requesting content from subfolders

I'm using WAMPSERVER to run a wordpress site that has to be acessible by the users in my network, like a environment for testing together.
Localhost works fine, but at first i couldn't access the aplication from other computers in the network. I created a rule to open the port 80, created an Alias in the Apache configuration, and it worked but the theme and any images inside subfolders wouldn't load and the console was returning lots of 404 responses.
I want to map the subfolders and its files that are under the 'base dir' of the site. I tried tons of options in the Apache conf. file but i couldn't make it.
Attached a printscreen of the responses, the apache conf file and the windows hosts file
Httpd.conf :
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#animamidia
DocumentRoot "C:\wamp\www\website"
ServerName www.animamidia
ErrorLog "logs/animamidia-error.log"
CustomLog "logs/animamidia-access.log" common
<Directory "C:\wamp\www\website\*">
Options FollowSymLinks Includes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Windows hosts file:
127.0.0.1 www.animamidia
The site with it's theme broken because the requisition returned a 404
Well i found the problem.
Even though i couldn't enter the wordpress-admin i decided to check the 'wp-config.php' file just in case something is wrong or missing.
And what i did find is that the 'Home-URL' and the 'WP-URL' were set at 'localhost/website' which means that all the requisitions would point at this location as a base directory.
All i had to do was to use the 'define' comand and set the site's URL to the machine's IP and now the environment is all set up for the guys over here to develop and test their stuff.

Categories