trailing-slash

URL fragments: a leading slash in your hash url - good or bad?

北战南征 提交于 2019-12-12 14:36:17
问题 Just need to know whether it is a good or not to have a leading slash in your hash url . For instance, site.come/#/directore/file/ or site.come/#directore/file/ I am asking this because backbone.js does not recommend the first option in their docs (personally I prefer the first option...), http://backbonejs.org/#Router-extend Note that you'll want to avoid using a leading slash in your route definitions So I want to make sure what the reasons are behind this that you want to avoid using a

removing multiple groups of slashes everywhere in URL in .htaccess

若如初见. 提交于 2019-12-08 10:09:00
问题 I currently have a website where guests are able to access each url with any number of slashes to separate folder names. For example, if a URL is supposed to be: http://example.com/one/two/three/four Then users could access the same page via any of the following: http://example.com/one//two///three////four///// http://example.com/one/two////three/four///// http://example.com///one///////////two////three/four/ http://example.com///////////one///////////two/three/four However, I want the above

How to dynamically set the base tag?

删除回忆录丶 提交于 2019-12-08 08:48:43
问题 We are using backbone routing, mod_rewrite, requirejs. The app is in a folder, not on the web root, so relative folder references are required for images,css, and js files (if we could use absolute folders the files would load). When accessing a route with a trailing slash none of the js and css files loads correctly unless there is an appropriate base tag set in the header. Like so: <base href="//localhost/myapp/" /> This solution works. The problem is we need to variablize the base tag so

How to remove trailing slash from URL in nginx only if directory doesn't exist?

戏子无情 提交于 2019-12-07 03:36:05
问题 I am running a server on nginx 1.4.1 with PHP-FastCGI. Currently I have it setup so that it removes trailing slashes from my URLs and issues a 301 redirect. However, when I visit a directory that exists, I am forced into a redirect loop. My current document root looks like this: - index.php (app) - webgrind - index.php - static - css Currently I cannot visit example.com/webgrind or any other directory. My access logs repeatedly read similar to: GET /webgrind/ HTTP/1.1" 301 178 "-" GET

How to remove trailing slash from URL in nginx only if directory doesn't exist?

谁说胖子不能爱 提交于 2019-12-05 08:47:03
I am running a server on nginx 1.4.1 with PHP-FastCGI. Currently I have it setup so that it removes trailing slashes from my URLs and issues a 301 redirect. However, when I visit a directory that exists, I am forced into a redirect loop. My current document root looks like this: - index.php (app) - webgrind - index.php - static - css Currently I cannot visit example.com/webgrind or any other directory. My access logs repeatedly read similar to: GET /webgrind/ HTTP/1.1" 301 178 "-" GET /webgrind HTTP/1.1" 301 178 "-" This is the server block in my nginx.conf: server { listen 80; server_name

Return string without trailing slash

谁都会走 提交于 2019-12-04 07:29:16
问题 I have two variables: site1 = "www.somesite.com"; site2 = "www.somesite.com/"; I want to do something like this function someFunction(site) { // If the var has a trailing slash (like site2), // remove it and return the site without the trailing slash return no_trailing_slash_url; } How do I do this? 回答1: Try this: function someFunction(site) { return site.replace(/\/$/, ""); } 回答2: function stripTrailingSlash(str) { if(str.substr(-1) === '/') { return str.substr(0, str.length - 1); } return

Why does IIS 7.5 adds a trailing slash on folders? Can we disable courtesy redirect for a URL Rewrite rule that removes trailing slash?

我的梦境 提交于 2019-12-03 05:39:58
IIS does URL cleanup on directories by adding a trailing slash. See this old docs from IIS 6: IIS generates courtesy redirect when folder without trailing slash is requested Why? Is the intent still relevant? Any security implications? How can I disable it to make this work with a URL Rewrite rule "RemoveTrailingSlashRule" When you add a rule under IIS 7.5 with URL Rewrite 2, the rule will not be applied to directories (using IsDirectory) and folders (using IsFolder). See this warning on Add a rule to append or remove the trailing slash symbol: This will create the RemoveTrailingSlashRule1:

Return string without trailing slash

冷暖自知 提交于 2019-12-02 14:13:04
I have two variables: site1 = "www.somesite.com"; site2 = "www.somesite.com/"; I want to do something like this function someFunction(site) { // If the var has a trailing slash (like site2), // remove it and return the site without the trailing slash return no_trailing_slash_url; } How do I do this? Try this: function someFunction(site) { return site.replace(/\/$/, ""); } ThiefMaster function stripTrailingSlash(str) { if(str.substr(-1) === '/') { return str.substr(0, str.length - 1); } return str; } Note: IE8 and older do not support negative substr offsets. Use str.length - 1 instead if you

Vanity URLs without trailing slashes on Apache

北慕城南 提交于 2019-12-02 04:15:44
问题 The code below rewrites all URLs in the /profiles/ directory on our site from example.com/profiles/name/ to example.com/name/ , but we'd also like to remove the trailing slashes to further simplify the resulting URLs to the prettier example.com/name -- just like on modern social media. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /profiles/$1 [NC,L] How can this be done (and done safely)? We have seen several solutions on Stumble Upon that if

Trailing slash before a query string. Bad practice?

*爱你&永不变心* 提交于 2019-11-29 06:19:32
I have a URL like www.example.com/store/ , which leads to a store page When a user clicks on a discount link, it adds the parameter ?discount=foo , so my link looks like this: www.example.com/store/?discount=foo . Everything is functional. But is it bad practice to have the forward slash before the query string in this situation? It’s valid: The path component may end with a slash ( / ). The query component starts with the first question mark ( ? ) in the URI. 来源: https://stackoverflow.com/questions/29855027/trailing-slash-before-a-query-string-bad-practice