Questions tagged [trailing-slash]

A slash sign at the end of a URL.

A slash sign at the end of a URL.

218 questions
319
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
  • 3,887
  • 3
  • 16
  • 19
232
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
  • 8,933
  • 19
  • 57
  • 97
31
votes
5 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
  • 4,097
  • 3
  • 22
  • 29
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,483
  • 18
  • 27
21
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
  • 54,112
  • 10
  • 112
  • 187
16
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
  • 183
  • 3
  • 11
14
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
  • 143
  • 2
  • 6
12
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,268
  • 7
  • 78
  • 135
12
votes
3 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
  • 4,449
  • 6
  • 40
  • 79
11
votes
2 answers

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"…
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
8
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
  • 751
  • 1
  • 7
  • 13
7
votes
4 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
  • 1,863
  • 6
  • 28
  • 50
6
votes
3 answers

Get request only works with trailing slash (spring REST annotations)

I have a Spring REST Controller: @RestController @RequestMapping(value = "/myresource") public class MyResourceController { ... } With a GET request method: @RequestMapping(method = GET, value = "/{value1}/{value2}/{value3}", produces =…
Nina
  • 671
  • 8
  • 22
1
2 3
14 15