pretty-urls not working with XAMPP and Laravel 5.8 - laravel

I use Laravel v5.8 and I was happy to use it in VMware with Ubuntu. Now I needed to change to a Windows Server 2012 with xampp.
There is one thing I cannot eliminate:
I can visit my page over
https://fancysubdomain.fancydomain.de/myapplikation/public
I've created links like
<a class="title" href="/entries/create" > FOO </a>
These links go to
https://fancysubdomain.fancydomain.de/entries/create
(watch the missing "myapplication" block) and Apache tells me that the requested URL was not found.
If I type
https://fancysubdomain.fancydomain.de/myapplikation/entries/create
in the address field of the browser it also doesn't work.
In the .env file, I've set
APP_URL= https://fancysubdomain.fancydomain.de/myapplikation/
I've edited \conf\app.php to
'url' => env('APP_URL', ' https://fancysubdomain.fancydomain.de/myapplikation/'),
There are no virtual hosts set up in httpd-vhosts.conf (I am not the administrator). Do I need to set them up to get what I want? Do I need to set up something else?

You should create a Vhost which should point to the public directory of you Laravel application.
It should look like this:
<VirtualHost *:80>
DocumentRoot "path/to/laravels/public/dir"
ServerName localhost
<Directory "path/to/laravels/public/dir">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
After this is done, the default .htaccess file will work and you have pretty url's.

I’ve finally found a solution. Thanks #J. Grunder stackoverflow
After I had changed these settings, I ran into a new problem with my links.
I had created links like
<a href=”/entries/create”>Create Entry</a>
Unfortunately, now the links pointed to
https://fancysubdomain.fancydomain.de/entries/create
(watch missing myapplikation element)
Of course, I could handle that with
<a href=”/myapplikation/entries/create”>Create Entry</a>
But there could be some problems if the user is at that place.
If somebody else runs in the same problem:
Use Laravel’s URL helper:
<a href=”{{ action('EntriesController#create') }}”>Create Entry</a>

Related

Css and js files stalling on xampp using the Laravel framework

Xampp was working fine until this morning when internal css and js scripts stopped loading with them 'stalling' in the browser.
here is an example of my code:
<link rel="stylesheet" href="/css/main-styles.css }}">
A strange thing though, its loading fine if i use http://localhost/, but if I use the vhost I created (http://cars.web), it doesnt work.
As I say it was working, then all of a sudden stopped.
To add, when I paste http://cars.web/css/main-styles.css into the browser, it doesn't load. but that is the path.
Vhost is as follows:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/xampp2/htdocs/cars/public"
ServerName cars.web
ErrorLog "logs/cars-error.log"
CustomLog "logs/cars-access.log" common
</VirtualHost>
UPDATE
When I remove that particular css file from my code, all the other css and js load fine
Please help.
You should use the asset() helper to avoid this kind of problems:
<link rel="stylesheet" href="{{ asset('css/main-styles.css') }}">
The asset function generates a URL for an asset using the current scheme of the request
https://laravel.com/docs/5.5/helpers#method-asset
After hours of searching for solutions I decided to reinstall xampp. The new version of xampp worked with the the same code.

CodeIgniter - 404 error after HTTPS configured

Helloooo,
I put HTTPS with letsencrypt and it works perfectly. The first page of my website is showing but after I click on a menu item, I got a 404 error.. I look into my controllers and everything is in.
Do you know any solution to this ?
Thank you :)
You need to set the AllowOverride directive in your apache configuration.
Change AllowOverride None to AllowOverride All
Set Allow Override

One host, two domains, two websites

So I want add second domain. I have website that uses domain1.com, but I want to add domain2.com which will show page from domain1.com/domain2_web/
I added domain at cpanel, but when I am going to domain2.com it redirects to domain1.com/domain2_web/
Is it possible to show domain2 website using only domain2.com ?
If you access to the raw Apache .conf file, you can set up a virtual host that has a seperate DocumentRoot.
<VirtualHost domain2.com:80>
DocumentRoot .../domain2/
</VirtualHost>

When people say "subdomain" do they mean VHosts with similar names, or mod_rewrite mappings?

I'm trying to set a cookie for use across different virtual hosts. Something similar to this has been asked multiple times here:
Cookies in subdomain doesnt work
how to access cookies on subdomain
Cookies And Subdomain
Setting cookies on domain/subdomain
cross subdomain login with cookies
Cookies and subdomains
They all mention a 'subdomain' but none describe what that is. If I have 2 Apache VHosts like so:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/
...
</VirtualHost>
<VirtualHost *:80>
ServerName home.example.com
DocumentRoot /var/www/home/
...
</VirtualHost>
If I log the user in at example.com and set the --and make sure to say the next word in a deep cookie monster voice-- cookie like so
setcookie( 'id', '1234', time()+24*3600, '/', '.example.com' );
Can I get id at home.example.com like so:
RewriteCond %{HTTP_COOKIE} \bid=[0-9]+\b
Or do these cross domain cookies only work when the subdomains are set up entirely within a single virtual host (presumably with mod_rewrite)
It's entirely based on the domain name. The same-origin check doesn't care about the underlying IP.
home.example.com could be:
The same as example.com
Different
Your local box
A subdomain set up by an attacker using DNS forgery.
It doesn't matter. It's still a subdomain.

Plone with Apache Proxy

I have a plone zinstance set up through Apache Proxy on OS X Server 10.5. The server is set up with a single vhost on port 80, with Proxy & Proxypass directives to the Plone zinstance:
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
However, I have some static HTML and PHP content that I want to display in an iframe via the plone site. I'm thinking I'll need to set up another vhost on a different port, then just specify the port # inline?
Set up a static URL that will not be proxied but served from Apache directly, like this:
ProxyPass /static !
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
Then configure /static to contain your static content.
I'd recommend rolling your configuration into a virtual host block. You can deliver static content directly form apache by rewriting a specific path. Here's an example
<VirtualHost *:80>
ServerName yoursite.com
Alias /static /var/www/some/path/
<Directory "/var/www/some/path">
Options Includes FollowSymLinks
AllowOverride All
</Directory>
# Zope rewrite.
RewriteEngine On
RewriteRule /static - [L]
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{SERVER_NAME}:80/Plone/VirtualHostRoot/$1 [L,P]
</VirtualHost>
Sorry, not enough information but I'll offer a couple of comments that might help point you in the right direction.
First, ProxyPassReverse is unnecessary as Plone already takes care of fixing up any self-referential urls. That is the point of the crazy url after all.
Another poster already showed how to configure ProxyPass to selectively bypass the proxy to Plone and serve from Apache directly.
Regarding the "additional vhost on port 8888". It's not clear what you mean by this. What is the extra vhost serving? If it's where your static html and php content is supposed to come from then restricting to localhost only means you're going to have to also configure an internal proxy to reach it. You can do that with Rewrite rules but that seems like an overly-complicated way to go in this usecase. Why is this vhost available to localhost only? For that matter, why are using a separate vhost... you can do this all (Plone, static files, and PHP) in just one vhost with the appropriate ProxyPass lines (or Rewrite lines if you need more flexibility).

Resources