Closed (won't fix)
Project:
Pathauto
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Dec 2007 at 13:47 UTC
Updated:
23 Sep 2014 at 23:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
billyboylindien commentedComment #2
gregglesI'm having a hard time understanding how this would help - can you explain what benefit this would provide?
I agree that adding a / to the end of the pattern doesn't work, but I'm not sure why... I think maybe the Drupal path aliasing system doesn't support it.
There is currently code which specifically removes leading and trailing slashes around line 265 of pathauto.inc, so this is being done on purpose.
Comment #3
gregglesI guess we don't need this.
Comment #4
KingMoore commentedI would like to see this also. I simply want the ability/freedom to specify aliases in pathauto with a trailing slash. Currently if I add a page, and specific 'mycat/' for the page reference, drupal gets confused (5.7) and I get a page not found for both 'mycat' and 'maycat/'.
It isn't nec. about a specific benefit, more than I want this added flexability when choosing an alias. I don't see a negative?
EDIT: it seems that the alias value is getting saved to the db ('mycat/'), so it must be when pathauto does the searching for the alias it strips out the slash, and then searches for just 'mycat' and finds no matches.
Comment #5
KingMoore commentedAfter looking at this more thoroughly, pathauto seems to be doing it's part - the URLs are saved to the url_alias table correctly as 'mycat/'. The problem must be in drupal core somewhere, when it looks at aliases for replacing, it will never find an alias like 'mycat/' because it trims off the slash before doing a search. This issue has nothign to do with pathauto :).
Comment #6
KingMoore commentedNevermind. I am getting confused about what the path module is doing and what pathauto is doing. The PATH module will let me specify and save a url to the url_alias table like this 'mycat/'. Pathauto will let me define a pattern like 'content/[title-raw]/' but the trailing slash does not get saved to the url_alias table.
Sorry for all the back and forth. Like I said, I was a bit confused about what role pathauto was playing in all of this.
Comment #7
KingMoore commentedHere's a patch that simply leaves the trailing slashes in Pathauto patterns rather than deleting them. Is this patch in an acceptable format? I created it with Zend/Eclipse.
In order for the pages to then be accessed with the /, a small patch would need to be applied to path.module (http://drupal.org/node/250525). However, applying this patch on it's own should not cause any problems.
Comment #8
greggles@KingMoore - thanks for providing the patch.
However, let's wait for #250525: Disallow trailing slashes in path aliases to get committed before doing anything to Pathauto.
Comment #9
aaronnewton commentedI am having some difficulty with trailing slashes for pages. Here is what I'm trying to create:
http://foo.com/research/
http://foo.com/research/projects/
However, up until now I have only been able to create http://foo.com/research & http://foo.com/research/projects - the trailing slash seems to break the URL alias. This syntax is more like a reference to a file path on a unix system than an actual directory reference (there are various SEO forums which discuss this problem).
To demonstrate this issue consider this example. If I want to link to http://foo.com/research from http://foo.com/research/projects with relative paths it looks like this -
../../research
Whereas if it were a directory we would just go up a level with
../
Hopefully this will illustrate that the trailing slash is in fact necessary for referencing a tree of resources. Is this an issue with my install or have other people had this problem? To emphasize this point further, please see the Apache docs on the HTML spec -
http://httpd.apache.org/docs/2.0/mod/mod_dir.html (see DirectorySlash Directive). Quote:
Typically if a user requests a resource without a trailing slash, which points to a directory, mod_dir redirects him to the same resource, but with trailing slash for some good reasons:
* The user is finally requesting the canonical URL of the resource
* mod_autoindex works correctly. Since it doesn't emit the path in the link, it would point to the wrong path.
* DirectoryIndex will be evaluated only for directories requested with trailing slash.
* Relative URL references inside html pages will work correctly.
To be fair Matt Cutts does point out that Google can sort of handle missing trailing slashes in this post -
http://www.mattcutts.com/blog/seo-advice-url-canonicalization/
BUT in this post he demonstrates how it can go wrong -
http://www.mattcutts.com/blog/dont-end-your-urls-with-exe/
Since search engines are using a regular expression to decide that a non trailing slash extension is a directory reference, the results can be unpredictable and you are therefore better off using the proper directory path with a trailing slash. Furthermore, if both the slash and non-slash URLs are reachable, this breaks down.
Also, @
The problem must be in drupal core somewhere, when it looks at aliases for replacing, it will never find an alias like 'mycat/' because it trims off the slash before doing a search. This issue has nothign to do with pathauto :).
Does anyone know if it is possible to override this *without hacking?
@ http://drupal.org/node/250525
This is not a great solution since you can still access both the 'file' path and the 'directory' path - it should at least 301 for the incorrect path.
Comment #10
j0hn-smith commentedgreat post aaronnewton
So does anyone know how to do a 301 redirect from domain.com/about-us to domain.com/about-us/? Hacks or no hacks, I don't care (sometimes a solution that uses hacks leads to one that doesn't).
Comment #11
j0hn-smith commentedI've written a simple module to provide a 301 domain.com/folder to domain.com/folder/, it won't be suitable for all situations but it's a good start. See http://drupal.org/node/540348
Comment #12
dave reidDrupal doesn't care about trailing slashes or not, so I don't think we should be adding this feature or not. I think the Global redirect module can redirect any non backlash-ending paths to ones with blackslashes.
Comment #13
DrupalKing commentedThere doesnt seem to be a solution here for someone who wants trailing slashes on their URLs. Global Redirect allows for a slash, but that in essence creates duplicate content.
I want pathauto to allow to add a trailing slash to URLs and make that the default behavior.
Comment #14
espirates commentedMany want this wordpress like function /page/ Drupal appears to not want it so that's why it's not built in. I personally think the / looks nicer then without and since Wordpress is the leading cms standard, it would be cool to at least provide Drupal users with some base functionality of Wordpress. How cool would that be Drupal with Wordpress functionality, people would not need to use Wordpress anymore.
Comment #15
tobykilroy commentedHas anyone had any luck with this yet?
I'm trying to add the trailing slash to taxonomy terms in URL aliases but no luck so far
Comment #16
novakov commentedstep 1:
file includes/path.inc near 10-15 line find next code
and change it to
step 2:
file sites/all/modules/pathauto/pathauto.inc near 300 line find code:
and replace it with
(we just commented one line)
now i have ability to set up patterns in pathauto settings with ending slash, like content/[title-raw]/ and it works great
i`m using Drupal 6.20 and Pathauto 6.x-2.x-dev, be carefull with updating Pathauto and Drupal core - dont forget to make changes again
Comment #17
langelhc commentedIf someone is going to need this funtionality you can see: https://www.drupal.org/project/trailing_slash