Giter VIP home page Giter VIP logo

Comments (14)

marcodafonseca avatar marcodafonseca commented on May 18, 2024 18

Typically URL Rewriting means just that. URL Rewriting. It's used a lot for making urls easier to read for users.

A simple, and probably most common example, would be for removing extensions from URLs. So, an "about" url could look something like this: "http://localhost:8080/about" which the URL Rewriter would change to "http://localhost:8080/about.html" in order for the correct file to be returned to the browser without requiring the input of the file extension in the address bar.

Is this possible to setup with this extension?

from vscode-live-server.

mjprogramation avatar mjprogramation commented on May 18, 2024 5

Hi I am using this plugin and it has saved me a lot of troubles. Thanks.
I want to know if there is a way to do a URL rewriting so that my app can always be run through the index.html like .htaccess in apache server

You said you want your app to run through the index.html, so you can do so by specifying the liveserver.settings.file = index.html And use a package for routing such as react router dom, if you’re using React.

from vscode-live-server.

LadyDefile avatar LadyDefile commented on May 18, 2024 4

So, I'm going to resurrect this thread because it's something I was actually hoping to see and didn't. What the OP is talking about is URL Rewriting. URL Rewriting is when you can type "domain.com/index" instead of "domain.com/index.html". This is usually done in the '.htaccess' file of the website on an Apache2 server and would look something like this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ /$1.html [L]

RewriteCond works like this
%{REQUEST_FILENAME} is the file address (i.e. /index)
The appended ".html" after that adds the html to turn "/index" into "/index.html"

RewriteRule just defines how to rewrite the the address using regex.

Essentially it says "if the file ./index doesn't exist but ./index.html does exist, get ./index.html instead".
This allows you to use links like "domain.com/index" instead of "domain.com/index.html"

from vscode-live-server.

ritwickdey avatar ritwickdey commented on May 18, 2024 1

I think, url rewriting means handling 404 error. (For spa)

Checkout the settings page. There is now new settings called file... for handling 404 error

from vscode-live-server.

ritwickdey avatar ritwickdey commented on May 18, 2024

Sorry? What is URL rewriting? Are you talking about SPA?

from vscode-live-server.

rjoydip-zz avatar rjoydip-zz commented on May 18, 2024

@kenshinman I am closing this issue because of since long time didn't got any response from issue reporter.

from vscode-live-server.

rjoydip-zz avatar rjoydip-zz commented on May 18, 2024

It could be file mounting. #72

from vscode-live-server.

marcodafonseca avatar marcodafonseca commented on May 18, 2024

Nudge

from vscode-live-server.

Romvnly-Gaming avatar Romvnly-Gaming commented on May 18, 2024

AGGRESSIVE NUDGE!

from vscode-live-server.

mjprogramation avatar mjprogramation commented on May 18, 2024

Sorry for that late, but maybe you're talking about this: liveServer.settings.file (Path to the entry point file. Useful for SPA)

from vscode-live-server.

marcodafonseca avatar marcodafonseca commented on May 18, 2024

That will resolve the issue for SPA's however that won't resolve the scenario I highlighted three years ago.

Typically URL Rewriting means just that. URL Rewriting. It's used a lot for making urls easier to read for users.

A simple, and probably most common example, would be for removing extensions from URLs. So, an "about" url could look something like this: "http://localhost:8080/about" which the URL Rewriter would change to "http://localhost:8080/about.html" in order for the correct file to be returned to the browser without requiring the input of the file extension in the address bar.

Is this possible to setup with this extension?

from vscode-live-server.

takkbbl avatar takkbbl commented on May 18, 2024

So, I'm going to resurrect this thread because it's something I was actually hoping to see and didn't. What the OP is talking about is URL Rewriting. URL Rewriting is when you can type "domain.com/index" instead of "domain.com/index.html". This is usually done in the '.htaccess' file of the website on an Apache2 server and would look something like this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*?)/?$ /$1.html [L]

RewriteCond works like this %{REQUEST_FILENAME} is the file address (i.e. /index) The appended ".html" after that adds the html to turn "/index" into "/index.html"

RewriteRule just defines how to rewrite the the address using regex.

Essentially it says "if the file ./index doesn't exist but ./index.html does exist, get ./index.html instead". This allows you to use links like "domain.com/index" instead of "domain.com/index.html"

but that doesn't answer the question, does it?

from vscode-live-server.

LadyDefile avatar LadyDefile commented on May 18, 2024

but that doesn't answer the question, does it?

Obviously not. I'm clarifying what the OP and I were hoping to get an answer on because people were suggesting that OP meant "SPA", file mounting, handling 404, etc. My comment contributes to the topic, yours is just rude, argumentative, and also doesn't answer the question either. I feel like I should be giving you a slow clap for being so impressively arrogant and idiotic.

from vscode-live-server.

Andrey-Svetlichny avatar Andrey-Svetlichny commented on May 18, 2024

Up

from vscode-live-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.