i have a site called example.com in different languages
when i call example.com/en - it opens the eng version
if i write example.com/fr - it opens the french version
its a one page project. So all is catched in the index.php. i read the url, explode it, and the i get the requested language. everything is working fine on localmachine
on my server, if i call example.com/en - it tries to open a path, that doesnt exist and then i get a 404 error
what do i have to do so my code works like on the local machine?
To start debugging your problem, use the Developer menus of your browser... the one that lets you see .network requests."
With it, you will very quickly be able to see exactly what URL was requested from the server and you'll see the 404
response being returned.
So, your first check is: *"well, was that the URL that I expected to be requested?"*
Then, if it was, check the server-side code to determine why it wasn't able to match that URL.
Remember also that, when your web-browser client requests things like blahblah/fr
, that /fr
bit is going to be seen (eg by Apache) as a different <Location>
. Carefully review the configuration documentation for your web-server of choice to make sure that it knows how to handle the URLs that it will be seeing. (There are several ways to do this so I really can't be more specific since you don't give us any clues as to your server-side setup...)
Please add following to the.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Note: If your web host doesn't allow the FollowSymlinks option, try replacing it with Options +SymLinksIfOwnerMatch.
This is basically configuration that works with Laravel framework. However, it should work for you as well but you need to set the path properly in the third rewrite rule.
The typical trigger for an error 404 message is when website content has been removed or moved to another URL. There are also other reasons why an error message could appear. These include:
To solve these problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.