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!
Related
I have a question about short URLs. Let me ask by giving an example.
We have this URL : www.domain.com/controller/function/parameter/?get=1
How can we show this URL like this : www.domain.com/ShortName
For example in joomla cms we have Alias that allows us to shorten the URL even with UTF-8 characters.
How can it be possible in php?
Thank you very much :)
You need to research URL rewriting.
Here is a very detailed article that provides a wealth of information and some examples:
http://corz.org/server/tricks/htaccess2.php
Here is an example.
In your .htaccess file you would enter something like this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/([0-9]+)-([a-z]+) http://corz.org/blog/index.php?archive=$1-$2 [NC]
This translates an unfriendly URL like this:
http://corz.org/blog/index.php?archive=2003-nov
into a friendly and easy to remember URL like this:
http://corz.org/blog/2003-nov
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.
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
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
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