Custom Domain URl for a directory - ruby-on-rails

I have this URL of my web application:
http://application.com/academies/1
now I want that my customer can map this url and get
http://my-academy.com/
Examples:
http://application.com/academies/1/dashboard
--> http://my-academy.com/dashboard
http://application.com/academies/1/dashboard/courses
--> http://my-academy.com/dashboard/courses
(this below is too hard to do?)
http://application.com/users/edit
--> http://my-academy.com/users/edit

What you need is a URL rewrite. If you are using apache as webserver you can add below rewrite rules.
RewriteRule ^/academies/1/(.*) http://my-academy.com/$1
RewriteRule http://application.com/users/edit http://my-academy.com/users/edit
For ruby-on-rails this article should help you.

Related

prevent users from seeing full path

I want to know if there is a way to prevent visitors on the website to see the full site url .. so for example instead of http://www.5eren.dk/index.php all the user see's is http://www.5eren.dk .. is this possible ?
If i am understanding you correctly check out .htaccess rewrite condition and rewrite engine.
For example to hide a file extension:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This should get you started.
Simply NO
However, depending on your server-side scripting technology you use on your website, such functionality may be applied by a mean of central script that call some URL on your website and render it as it is being the requested script with some param.
For example:
Suppose the following URL
http://myexample.com/secrets/pages/output.php
Now we may request it using some routing script as follows:
http://myexample.com/routing.php?routeID=123
Using some database inside your routing script you may able to call or include the secrets/pages/ouput.php

don't display .php extension in address bar(php)

First of all this method clearly working on github, for example pages showing done:
https://github.com/account
https://github.com/inbox
There is no .php extension at all + not needed ?page=account or ?page=inbox
In my opinion it's done via .htaccess.
Maybe someone knows how it should look in order to archieve same effect like github site ?
This can be achieved using mod_rewrite for apache
You put a .htaccess file in your document root and give it rules (Regular Expressions) to match the called URLs with
It looks similar to this:
RewriteEngine On
# rule to call MyPage.php if you call the URL http://yourdomain.com/MyPage
RewriteRule ^(.*)$ $1.php
# rule to add GET params
RewriteRule ^(.*)$ index.php?page=$1
There are several tutorials regarding mod_rewrite on the internet

how to simplify the url

Hi:
In my website I found that their url are very simple like:
http://example.com/questions/4486620/randomaccessfile-probelm
And generally the url should like:
http://example.com/questions?xx=4486620&title=randomaccessfile-probelm
That's to say there is no request parameters combined by "&" in the url.
How did they make it? Is there any framework?
UPDATE:
My application works under tomcat.
On an apache web server you can do this using mod_rewrite http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Here is an example along with a tutorial...
The Apache rewrite engine is mainly used to turn dynamic url’s such as www.yoursite.com/product.php?id=123 into static and user friendly url’s such as www.yoursite.com/product/123
Read more about htaccess And mod_rewrite Tutorial by Blogstorm SEO Blog
RewriteEngine on
RewriteRule ^product/([^/\.]+)/?$ product.php?id=$1 [L]
Another example, rewrite from:
www.yoursite.com/script.php?product=123 to www.yoursite.com/cat/product/123/
RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2
Read more here that example by the way is copied from http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/ - assigned kudos!

Apache: mod_rewrite: generate URL based on passed PArameters

well i have been use static mod_rewrite rules for some time now like i used to do this
RewriteRule ^Animals\.html$ wallpapers.php?f=Animals&of=0&s=Newest
but now what i want to do is create the URL of the leech pages with keywords... LIKE
preview.php?image=26
preview.php is my leech page & 26 is my imageID(primary key) in the database, which corresponds to a imageName, i want the mod_rewrite to create the page URL using that image name... i have been googling about but could find some usable tutorial... can any one help me learn how to do it?
solved it myself
RewriteRule ^([^/\.]+)/?\.html$ preview.php?image=$1

Mod_rewrite not working properly

I have this in my .htaccess file...
RewriteEngine on
RewriteRule ^/invite$ /invite.html
It's meant to let a user access this url:
http://mysite.com/invite
and display the invite.html page. I don't want to redirect the user, but just show them the invite.html page from a better looking URL.
When I browse to http://mysite.com/invite though, I get a 404 not found error.
Is there anything I'm doing wrong? I've tried looking at tutorials for using mod_rewrite but I seem to be doing what they're telling me too...
Thanks!
I don't think there should be a / in that RewriteRule:
RewriteEngine on
RewriteRule ^invite$ invite.html
Did you make sure that AllowOverride All is set for the directory where the .htaccess file lies? Else the file might be ignored.
If this isn't the case, you should check out Apache's log files for more hints (/var/log/apache on Linux).
You're missing a RewriteCond directive. That's the one that does the actual testing Condition to match a URL. The RewriteRule is invoked only when one or more RewriteConds are matched.

Resources