vanity-url

Rails 5 - Create vanity route for each instance of model

萝らか妹 提交于 2019-12-24 10:17:09
问题 I know there has to be a cleaner way of doing this but I haven't written code in a while and am drawing a blank. I have a model called Link that has a Title, Slug and Destination. Destination is the location to redirect (mydomain.com/instagram would redirect to my instagram account). Slug is to customize the slug for friendly_id. This is the code in my routes.rb and it works but it feels gross. Link.all.each do |link| get "/#{link.slug}", to: 'links#show', :id -> link.id end Is there a better

What kind of route would I need to provide vanity urls?

坚强是说给别人听的谎言 提交于 2019-12-18 05:25:09
问题 I'd like to provide my users a vanity url, something like: www.foo.com/sergio What kind of route would I need to create? Imagine I have the following controller and action, how can I map a vanity URL to that controller? public ActionResult Profile(string username) { var model = LoadProfile(username); return View(model); } Here is what I've tried and what happens: Option A: Every url is caught in this route, meaning every URL I type directs me towards the Account controller, instead of only

Is it possible to get a reference to the vanity URL used after redirection?

倖福魔咒の 提交于 2019-12-12 03:17:27
问题 I have a page http://localhost:4502/content/project/en/mypage.html and it has couple of vanity URLs set as /content/project/vanity-1 /content/project/vanity-2 So any request from the above two vanity URLs are being redirected to /mypage.html . Is it possible to get the vanity URL request from where the page is redirected to? i.e how can I find from which vanity URL the request is coming from? request.getRequestURL() gives me . ./mypage.html but I need to get the vanity URL request. 回答1: You

mod_rewrite: multi-level URL using a request parameter

别说谁变了你拦得住时间么 提交于 2019-12-11 12:13:57
问题 I currently have this set up and working fine inside a users folder. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?i=$1 e.g 127.0.0.1/site/users/admin goes to 127.0.0.1/site/users/index.php?i=admin Now as this is for a profile page, how would i do something such as this. users/admin/activity So that it would show the activity page for that user? I am totally confused on how i would go about this. Would it be best to make

Create vanity URLs in a LAMP configuration

馋奶兔 提交于 2019-12-05 03:08:27
问题 What is the best way to create user vanity URLs under a LAMP configuration? For example, a user profile page could be accessed as follows: http://www.website.com/profile.php?id=1 Now, if a user enters a "vanity URL" for their profile I would want the the vanity URL to load the page above. For example, if a user selects "i.am.a.user" as their vanity URL and their user id in the database is 1 then http://www.website.com/profile.php?id=1 would be accessible by that URL and http://www.website.com

Create vanity URLs in a LAMP configuration

梦想的初衷 提交于 2019-12-03 20:40:01
What is the best way to create user vanity URLs under a LAMP configuration? For example, a user profile page could be accessed as follows: http://www.website.com/profile.php?id=1 Now, if a user enters a "vanity URL" for their profile I would want the the vanity URL to load the page above. For example, if a user selects "i.am.a.user" as their vanity URL and their user id in the database is 1 then http://www.website.com/profile.php?id=1 would be accessible by that URL and http://www.website.com/i.am.a.user . I'm aware of mod rewrites in .htaccess but not sure how that would work here. As I

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

How-to? Vanity URL & ignore .PHP extension with .htaccess

别来无恙 提交于 2019-12-01 12:23:38
I've got the following .htaccess working perfectly: RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .* - [L] RewriteRule ^(.*)$ http://www.mysite.com/mypage.php?u=$1 [NC] This will allow me to write urls like this: http://www.mysite.com/peter => http://www.mysite.com/mypage.php?u=peter But what if I want have an aditional rule to avoid writing the .php extension for existing files? http://www.mysite.com/contact (contact.php exists on file) I tried adding this to my curr htaccess (but doesnt work): RewriteCond %{REQUEST_FILENAME} !-d

How-to? Vanity URL & ignore .PHP extension with .htaccess

本小妞迷上赌 提交于 2019-12-01 11:36:34
问题 I've got the following .htaccess working perfectly: RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .* - [L] RewriteRule ^(.*)$ http://www.mysite.com/mypage.php?u=$1 [NC] This will allow me to write urls like this: http://www.mysite.com/peter => http://www.mysite.com/mypage.php?u=peter But what if I want have an aditional rule to avoid writing the .php extension for existing files? http://www.mysite.com/contact (contact.php exists on

What kind of route would I need to provide vanity urls?

妖精的绣舞 提交于 2019-11-29 08:57:23
I'd like to provide my users a vanity url, something like: www.foo.com/sergio What kind of route would I need to create? Imagine I have the following controller and action, how can I map a vanity URL to that controller? public ActionResult Profile(string username) { var model = LoadProfile(username); return View(model); } Here is what I've tried and what happens: Option A: Every url is caught in this route, meaning every URL I type directs me towards the Account controller, instead of only foo.com/[USERNAME] . No good. public static void RegisterRoutes(RouteCollection routes) { routes