I am new to vue js. I have created a project using vue cli 3.
The URLs generated contain #/ at the end, example http://localhost:8080/vuejs#/
I want to get rid of trailing #/, I have tried mode: "history" in router.js file as well as added .htaccess file in root directory with following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
but it returns a blank page without any error.
Can anyone please help me
Replace
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
with
FallbackResource /index.html
https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
Related
I am trying to remove .html from url which aren't posted using WordPress using below code :-
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
And the htaccess provided by WordPress is :-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The html file I am trying to remove html extension from is not a post but external file uploaded in c panel, any help would be greatly helpful thanks! embers of divinity
I'm on shared hosting where some website live.
I have to move a ZendFramework2 on this server by adding it in a directory from the root (dir name = site). Controllers and actions are working right but I can't load any css, images or javascript.
Here are my directories :
/root/website1 (example.com/website1)
/root/website2 (example.com/website2)
/root/site (example.com/site)
/root/site/application
/root/site/data
/root/site/library
/root/site/public
/root/site/public/css
/root/site/public/fonts
/root/site/public/img
/root/site/public/js
/root/site/public/.htaccess
/root/site/.htaccess
.htacces in /site folder
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /site/public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/site/public/.*$
RewriteRule ^(.*)$ /site/public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^site/public/.*$ /site/public/index.php [NC,L]
.htacces in /site/public folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /site/index.php [NC,L]
css tag :
<link href="/css/global.css" rel="stylesheet" type="text/css" media="screen" />
Can i redirect /css/global.css to load /site/public/css/global.css ?
Sure, i could change for ...
<link href="/site/css/global.css" rel="stylesheet" type="text/css" media="screen" />
... but i prefer not to change href
Any help is very welcome!
I would create only one .htaccess file to solve all your problems. Please put this into your /root folder and delete the other .htaccess files.
# This first part should be done by the webserver,
# if not than thing about to change you hoster but I put it here:
# Preventing direct access to any .ht file (.htaccess, .htpasswd, etc.)
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
Options +FollowSymlinks
Options -Indexes
# Start to Rewrite
RewriteEngine On
# For all URL starting with /css, /fonts, /img or /js
RewriteCond %{REQUEST_URI} ^/?(css|fonts|img|js)(/.*)?$ [NC]
RewriteRule ^.*$ /site/public/%1%2 [L]
# Redirect all to the Application if not done already
RewriteCond %{REQUEST_URI} !^/?site/public/index\.php [NC]
# but not if the URL starts with css, fonts, img or js
RewriteCond %{REQUEST_URI} !^/?(css|fonts|img|js)(/.*)?$ [NC]
# or if request is a real file
RewriteCond %{REQUEST_FILENAME} !-f
# or if request is a real directory but not the root directory
RewriteCond %{REQUEST_URI} ^/?$ [OR]
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite the rest to the index.php file in your public folder
RewriteRule ^.*$ /site/public/index.php [NC,L]
So I've got the following code which shows all the files of /guides at the root of my site. I would however also like to show all of the files of /news at the root of my site but I can't figure out how I could do both of these at the same time.
Like this:
example.com/guides/google --> example.com/google
example.com/news/youtube --> example.com/youtube
Simply duplicating the rewrite rule and changing it to /news throws a 403 and seems to mess everything up. Here's my current code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /guides/$1 [L]
Thank you and sorry for the novice question!
You can use:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/guides/$1 -f
RewriteRule ^(.*)/?$ /guides/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/news/$1 -f
RewriteRule ^(.*)/?$ /news/$1 [L]
Every time when I click on an URL I get a 404. That's because the page can't be found. But when I add a question mark right after the .domain the page is found. This was not the problem when I had the website hosted in a subdomain folder. A question mark is required to visit a page and I don't want to have the question mark.
Please see the url: http://www.ankehesselmann.nl/
I'm using StaceyApp
This is my .htaccess
RewriteEngine on
# Some hosts require a rewritebase rule, if so, uncomment the RewriteBase line below. If you are running from a subdirectory, your rewritebase should match the name of the path to where stacey is stored.
ie. if in a folder named 'stacey', RewriteBase /stacey
RewriteBase /stacey
ErrorDocument 404 /404.html
# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]
#Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]
# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?$1 [L]
# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]
I'm guessing the RewriteBase is set to the wrong folder in your .htaccess
Though I cannot explain why it works with the question mark as you said, I would try setting the RewriteBase correctly.
You have to put the sub-folder (path from domain name until your index-file) if you have any. E.g.:
Website located at: example.com/folder1/sub/
RewriteBase /folder1/sub/
If your website doesn't have a sub-folder:
RewriteBase /
You may try removing the line if you haven't got a sub-folder, but it should not make any problems if set to / (slash).
Hi I have certain urls which i dont want to access by users but unfortunately can't remove them as they are part of my url. For example i have url like this:
example.com/places (want to revoke access to this page)
example.com/places/in/jaipur/ (location is selected)
example.com/places/restaurants/(want to revoke access to this page)
example.com/places/in/jaipur/restaurants/ (location is selected)
In general I want them to 404 if no location is selected.
Just updated the code in htacess but still urls are accessible:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{THE_REQUEST} \s/+places(/restaurants/)?[?\s] [NC]
RewriteRule ^ - [L,R=404]
</IfModule>
# END WordPress
In your .htaccess file you can do the following:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/places/ [OR]
RewriteCond %{REQUEST_URI} ^/places/restaurants/
RewriteRule ^(.*)$ - [R=404,L]
You can use this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+places(/restaurants/)?[?\s] [NC]
RewriteRule ^ - [L,R=404]