Octo-Labs / middleman-alias

Easy aliases/redirects for Middleman that are friendly to the Googles.
MIT License
35 stars 14 forks source link

.htaccess-based aliases #8

Closed Tuckie closed 8 years ago

Tuckie commented 9 years ago

Would it be possible to add an option (or two) to this for generating an .htaccess file instead of the redirect pages? If possible, I would like to preserve the referrer, and a server-side redirect seems to be the only way to do it.

RewriteRule #{@alias_path} #{resource.url} [QSA, R=301]

Taking things a step further, we could even do something like:

RewriteRule #{@alias_path} #{resource.url}?#{@alias_parameter}=#{url_encode(@alias_path)} [QSA, R=301]

This would allow tracking on the referrer as well as the alias itself.

Thoughts?

jagthedrummer commented 9 years ago

I'm open to this as a concept but I won't have any time to dedicate to it for the foreseeable future. I do love pull requests though. :)

Tuckie commented 9 years ago

Great to know :) I'll probably take a shot at it next week.

rmm5t commented 8 years ago

@Tuckie Are you sure this has to be a new feature?

Couldn't you just iterate over all sitemap.resources that are also Middleman::Sitemap::AliasResource instances and build your own .htaccess resource using a standard middleman template.

Tuckie commented 8 years ago

I suppose you're right; closing!