I am working on laravel 5.4 project.I want to remove public word from url I followed this link https://hdtuto.com/article/laravel-remove-public-from-url-using-htaccess to remove public.
These steps removed the public word from xampp server but not working on live server.
In root folder make .htaccess file with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Related
This question already has an answer here:
Cannot load routing modules after building in Angular
(1 answer)
Closed 2 years ago.
I have a angular 9 project. I deployed it to server. On server when I refresh angular app, it shows error :
Error:
start
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
end
we are using below for development
server : Apache
frontend : angular
backend : nodejs
I did not understand what happened. I tried this solution
link to solution what I found
but We don't want # in over url. with out #, we want solution.
please suggest proper solution.
thanks for your time.
Build your app like this using angular cli.
ng build --prod --base-href /<project_name>/
Try with this in .htaccess one and let me know as It works for me.
Put .htaccess in src folder (final path for is src/.htaccess) and give the file path in angular.json inside "assets"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
Reference
You need to place a .htaccess file on the root of the deployed project i.e. along with index.html. Below is the code to be written in the above file.
<IfModule mod_rewrite.c>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]
Please see the below image -
I made a website, I threw it on hosting and I have a problem. Well, on the hosting, photos and .css files work normally and load normally, but not on localhost.
I noticed that the problem is the path to which he gives to photos or .css files
For example that looks for some image:
<img data-src="{{ base_url() }}/public/images/background-pattern4.png" class="background-pattern-4" uk-img>
And this way works on hosting, but it does not work on localhost. However, when I remove 'public' from the path, it works the other way around. At localhost works and not on hosting.
I have 2 .htaccess files, first on root folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/ [L]
</IfModule>
And second.. in public folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
What can I change to make the tracks work in both sides?
Are you using Laravel framework? the syntax looks like a blade template syntax. If yes then you might want to use the asset helper function like so:
<img data-src="{{ asset('images/background-pattern4.png') }}" class="background-pattern-4" uk-img>
Here's the documentation link
I'm new to Yii2,
here is the website almousa.net
the issue here that I can not go to the backend, I always get The requested page does not exist and the page title Not Found (#404)
I tried everything from changing the .htaccess to changing the url
how can I solve that?
I noticed that there are no index.php in the website base folder and as if all the requests are going to the front end
Even I have installed a fresh copy of Yii2 advanced and following standard steps I got everything OK. But the same problem like you mentioned here that the backend was not working.For this I added an additional .htaccess file inside backend folder(/backend) with the following code:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
Please do follow and I hope it helps.Your config settings must be correct in addition to 1 more .htaccess inside backend/web folder with the following code:
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
I have a cakePhP site all set up. It has its "webroot" directory and some sub-directories that each have their own "app" directory. They all work fine. Now I want to set up a sub-directory that runs from just an "index.html" file, no "app" directory or cakePhP directory structure with a Controller file etc. It would be a pure HTML sub-directory.
If I just add a subdirectory containing just an "index.html" file (no ".htaccess" file in it) I get a cakePhP error saying the controller file for that directory is missing.
The ".htaccess" file of the overall "webroot" directory looks like this. I cannot change that ".htaccess" file because the other sub-directories depend on those rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Does anyone know what I need to do e.g. set up a local .htaccess file in my sub-directory to make my sub-directory work with just HTML?
Inside webroot/html folder create some html files, index.html, ...
test http://somesite.com/html/index.html
A possible solution is to hard code your sub-directory as the the first RewriteRule. Let's say your regular HTML sub directory is called "html".
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule /html$ app/webroot/html [L]
RewriteRule /html/(.*) app/webroot/html/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This way it will check if you are trying to access the sub directory before the rules for Cake are checked. I haven't tested this, but give it a try.
I have a test project on Laravel 4, and I'm still new to this. I'm still working on wamp (localhost). I have already made it work as long as laravel is installed on the root path of wamp (..wamp/www), but when I try to create another folder (..wamp/www/testproject) and install laravel there, the routes are not working anymore except for localhost/testproject/laravel/public.
to summarize:
--The working one---
C:/wamp/www/laravel = the folder where laravel was installed
localhost/laravel/public = working, "You have arrived" page
localhost/laravel/about = working about.php route
--The one with errors--
C:/wamp/www/testproject/laravel = the folder where laravel was installed
localhost/testproject/laravel/public = working, "You have arrived" page
localhost/testproject/laravel/about = not working about.php route
localhost/testproject/laravel/index.php/about = working, and I don;t know why
can someone help me with this? why is it that the "about.php" page is not working on the subfolder? :(
EDIT: .htaccess file content
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
here is the screenshot for the routes..
Add RewriteBase /laravel/public below RewriteEngine On in .htaccess