Skip to content

Clean URLs and Apache httpd: use .htaccess #1824

Answered by Martien
Martien asked this question in Q&A
Discussion options

You must be logged in to vote

Context – …you are creating a project in Observable Framework.
Wish – You want to host your framework using Apache, also using clean URLs.
ThereforeInside a <VirtualHost *:80> block, add:

#-----------
# Clean URLs
# /hello can also be accessed as /hello.html, and / can be accessed as /index and /index.html.
# By default, Framework generates “clean” URLs by dropping the `.html` extension from page links.
# Not all webhosts support this.
#-----------

#LogLevel debug rewrite:trace8
#ErrorLogFormat "%M"
#ErrorLog "/log/apache-clean-urls.log"

RewriteEngine On

# Redirect URIs with trailing slashes except root `/` to remove the slash
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)/$ /$1 …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Fil
Comment options

Fil Nov 15, 2024
Collaborator

Comment options

You must be logged in to vote
2 replies
@Martien
Comment options

@Fil
Comment options

Fil Nov 19, 2024
Collaborator

Answer selected by Fil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #1822 on November 15, 2024 17:08.