Right now I have to go to “https://trapeezee.bss.design/support.html
”
and i’d like it to go there with just “https://trapeezee.bss.design/support
”
Can this be done in BSS ?
Right now I have to go to “https://trapeezee.bss.design/support.html
”
and i’d like it to go there with just “https://trapeezee.bss.design/support
”
Can this be done in BSS ?
Unfortunately not, although I’d suggest posting this as a suggestion in the Ideas category
Create a subfolder called support, then rename your support page to https://trapeezee.bss.design/support/index.html then you will be able to access it via https://trapeezee.bss.design/support
Brilliant, never thought of that one… thanks!!
Hmmm, this works inside Martins captured environment (Published or Previewed), but not on my web server… it seems to have moved the root down to /setup folder, so it finds the index.html in /setup, but can’t find the assets, as it’s looking for them under /setup/assets… (See Screenshot)… any suggestions?
(Sorry, my original question used /support as example, and this is switched to /setup, but exactly same thing)
@martin did you quietly know this was going to happen? If so, is there a fix? THANKS!!!
If you’re using your own server then change the htaccess file:
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
Then use your normal www.example.com/setup.html
This will strip the extension making it www.example.com/setup
How about with Nginx ?
Thanks
In Nginx, you can achieve the equivalent behavior of the Apache RewriteRule
and RewriteCond
directives using the rewrite
directive. Here’s how you can translate
@richards provided Apache rules into Nginx configuration:
.html
URLs to the URL without the .html
extension..html
extension to serve the corresponding .html
file if it exists.Add the following configuration to your Nginx server block:
server {
listen 80;
server_name example.com; # Replace with your domain
root /path/to/your/document/root; # Replace with your actual document root
index index.html;
# Rule 1: Redirect requests ending in `.html` to the URL without `.html`
rewrite ^/(.+)\.html$ /$1 permanent;
# Rule 2: Internally rewrite URLs to add `.html` if the file exists
location / {
try_files $uri $uri.html $uri/ =404;
}
}
Rule 1:
rewrite ^/(.+)\.html$ /$1 permanent;
This captures any URL ending with .html
and redirects it to the same URL without the .html
extension using a permanent (301) redirect.
Rule 2:
location / {
try_files $uri $uri.html $uri/ =404;
}
This tries the following in order:
$uri
)..html
extension ($uri.html
).$uri/
)./etc/nginx/sites-available/example.com
).sudo nginx -t
Ensure there are no errors.sudo systemctl reload nginx
After this, your Nginx server will perform the same functionality as the Apache rewrite rules.
Wow, thanks so much guys!
@kuligaposten thats a great Nginx explanation.
I’ve read about the rewrite and try_files Directives, but never needed to use.
I’ll be trying in next day or two.
Fred
I guess it would be nice for this functionality to be supported inside BSS, so we could use bss.design it for an emergency backup and test site without having to modify anything on the server end (@martin hint hint?)
@martin is there any reason you couldn’t just easily add the same rewrites into your encapsulated environments?
Then both the bss.design/publish and exports would work the same!
How do you guys handle redirection to external website?
Thanks Very Much! This works… however… Nginx path is case sensitive (on Linux droplet/VPS). So it will pick up XYZ.com/test but not XYZ.com/Test… How do you handle this? (or do you)? I’m reading I need Lua or Perl, etc… can’t really find a good full how-to to do it.
try this
server {
listen 80;
server_name example.com; # Replace with your domain
# Replace with your actual document root
root /path/to/your/document/root;
index index.html;
# Rule: Redirect requests for any `.html` file
# to the same URL without `.html`
rewrite ^/(.*)\.html$ /$1 permanent;
# Rule: Internally rewrite URLs to add `.html` if the file exists
location / {
try_files $uri $uri.html $uri/ =404;
}
}
Rewrite Rule:
rewrite ^/(.*)\.html$ /$1 permanent;
.html
extension for any file, regardless of whether the filename is lowercase or has uppercase letters. It matches any .html
file and permanently redirects to the same path without the .html
extension.example.com/test.html
will be redirected to example.com/test
example.com/Test.html
will be redirected to example.com/Test
try_files
Directive:
try_files
directive is used to resolve the path for internal requests:
$uri
)..html
($uri.html
).$uri/
).404
.example.com/test.html
→ Redirects to example.com/test
(no .html
).example.com/Test.html
→ Redirects to example.com/Test
(no .html
).example.com/other.html
→ Redirects to example.com/other
(no .html
).example.com/test
→ Resolves to test.html
internally, if the file exists.example.com/Test
→ Resolves to Test.html
internally, if the file existsThanks Very Much! This works… however… Nginx path is case sensitive (on Linux droplet/VPS). So it will pick up XYZ.com/test but not XYZ.com/Test… How do you handle this? (or do you)? I’m reading I need Lua or Perl, etc… can’t really find a good full how-to to do it. If I don’t trap the uppercase users (eg converting all to lowercase), I may miss some users / customers…
Here is a post how to do it with Lua or with a php script