Questions tagged [trailing-slash]

A slash sign at the end of a URL.

A slash sign at the end of a URL.

263 questions
401
votes
9 answers

When should I use a trailing slash in my URL?

When should a trailing slash be used in a URL? For example - should my URL look like /about-us/ or like /about-us? I am fully aware of the SEO-related issues - duplicate content and the canonical thing; I'm trying to figure out which one I should…
Denis
  • 4,718
  • 5
  • 18
  • 20
280
votes
12 answers

Return string without trailing slash

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…
Ryan
  • 9,821
  • 22
  • 66
  • 101
48
votes
6 answers

How can I make a trailing slash optional on a Django Rest Framework SimpleRouter

The docs say you can set trailing_slash=False but how can you allow both endpoints to work, with or without a trailing slash?
Ryan Allen
  • 5,414
  • 4
  • 26
  • 33
26
votes
3 answers

Create new URI from Base URI and Relative Path - slash makes a difference?

Why does a slash make difference when using new URI(baseUri, relativePath)? This constructor creates a Uri instance by combining the baseUri and the relativeUri .. And, how can can a relative path be appended safely/consistently to a URI? var…
user2864740
  • 60,010
  • 15
  • 145
  • 220
22
votes
1 answer

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?

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…
Malartre
  • 1,511
  • 18
  • 28
21
votes
4 answers

Add Trailing Slash .htaccess

I'm trying to get the following effect (using this local file http://localhost/[company_name]/[project_name]/.htaccess): http://localhost/[company_name]/[project_name]/page-1 (adds slash) http://localhost/[company_name]/[project_name]/page-1/ (does…
Simon
  • 5,464
  • 6
  • 49
  • 85
20
votes
1 answer

Trailing slash before a query string. Bad practice?

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…
Max Martel
  • 203
  • 3
  • 6
17
votes
4 answers

laravel trailing Slashes redirect to localhost

When I try this http://localhost/Testlaravel/public/users/login it works. But when I try http://localhost/Testlaravel/public/users/login/ it redirects me to http://localhost/users/login/ Any idea why? This my htaccess file
user3213240
  • 193
  • 1
  • 3
  • 11
15
votes
3 answers

How to force windows cmd tab complete to add a trailing slash to directory names

On the rare occasion that I have to use a windows command prompt rather than bash, it drives me nuts that tab completion doesn't add a slash to the end of directory names. Is there a setting or script that I can run to force the full completion?
Jonathan Day
  • 18,519
  • 10
  • 84
  • 137
12
votes
3 answers

Laravel 8 misbehaves on trailing slash

There is a problem occurring while using APIs with trailing slash. Route Route::post('user/register','UserController@register'); It's working fine when I called this route POST from the postman/website, but I called this route from mobile with a…
Muhammad Shareyar
  • 772
  • 2
  • 7
  • 21
11
votes
1 answer

Enforce trailing slash in Rails Routing

Adding a trailing slash in your links is easy enough with {:trailing_slash => true}, but this doesn't account for if a user types in a non-slashed url. Is there a way to enforce trailing slashes via redirects in the router? get "/:controller/:id"…
trevorgrayson
  • 1,806
  • 1
  • 21
  • 29
9
votes
4 answers

Weird Trailing Slash at End of Twitter Message

I am using the following code to show a page with a Twitter box already filled in with a message: Click me However, on the page, I am getting this…
steacha
  • 171
  • 5
  • 13
9
votes
3 answers

IIS Forces Slash even with URL Rewrite to remove it

I am unable to remove the trailing slash my site's URLs even with the URL rewrite from: http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/. Frustrating really since it should be so simple but my attempts have not produced any results. I…
fseminario
  • 801
  • 1
  • 9
  • 13
8
votes
5 answers

Remove trailing slash using .htaccess in WordPress

I'm looking for a way to remove trailing slash for all WordPress URL's. I found similar answers like this one but it doesn't work when there's WordPress .htaccess rules before. Here is my current WordPress .htaccess: # BEGIN WordPress
6
votes
1 answer

Remove trailing slash if not a directory with apache

I have the following rewrite rules: #remove the www. RewriteCond %{HTTP_HOST} ^www.website.co.uk$ [NC] RewriteRule ^(.*)$ http://local.website.co.uk/$1 [R=301,L] #this removes php extention RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$…
AJFMEDIA
  • 2,093
  • 6
  • 29
  • 52
1
2 3
17 18