I've seen it before and I have no clue how to do it or what to look for on google to find it.
Basically I'd like to know how to get these shortened urls to work, what i mean is for example
this: http://website.com/index.php?id=666
turned into this: http://website.com/666
Is there some way to do this through php or do people actually go around making maps for each id?
thanks
Hi there depends what server you are on but if you are using a server with apache that has mod rewrite you can use a htaccess rule.
So an example would be:
first create a .htaccess file then paste in the following content:
RewriteEngine on
RewriteRule ^([^/\.]+)?$ index.php?id=$1 [L]
Related
I know this question has been ask often. I leverage the links here but still cannot get it to work
source: link
what am trying to achieve:
I have Original URL:
Eg: http://localhost/followersid.php?id=101data
which am trying to rewrite as follows
Eg: http://localhost/followers
.htaccess Code
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/\followers$ followersid.php?id=$1
My ISSUE: When I type http://localhost/followers in the url, it says The requested URL was not found on this server whereas followersid.php is in the same directory with .htaccess files
It was a regex issue. this is what solve the problem
RewriteRule ^([a-zA-Z0-9_-]+) followersid.php?id=$1
I am developing a website, however I am trying not to have the unattractive url being displaced example instead of : /my_project/master_page.php?page=home and would like to display /my_project/project/welcome and so on, I am trying to achieve this by using mod_rewrite and .htaccess in the site's root directory.
The code is as follows below:
RewriteEngine On
RewriteRule ^project/([^/\.]+)/?$ master_page.php?page=$1 [L]
However I must add I do need some major assistance in achieving this, Thank You.
I'm creating a basic routing system, so my URL's would look like this:
www.domain.com/index.php/controller
Only problem is, when I go to that address, I get a 404. Is there any way to overwrite this with PHP (without using .htaccess)?
the index.php file would need to be your bootstrap file that would load the controller depending on what's being requested to it, but without using mod rewrite the url would be something like:
www.domain.com/index.php?url=controller
I've set up something like this before - In mine I had to have apache do redirects with mod_rewrite: mine sends www.domain.com/controller to www.domain.com/index.php?route=controller - should be similar to what you're after I think.
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
Hope that helps.
I'm in a situation where my web page have the following types of URL's
http://mysite.com/?type=home
http://mysite.com/?type=aboutus
http://mysite.com/?type=contactus
For the end users I need it to display like the following:
http://mysite.com/home
http://mysite.com/aboutus
http://mysite.com/contactus
This means, the user is not aware that the URL have a request parameter "type" in it.
I'm not sure it is possible or not.
Please help me to get to a solution.
EDIT: I searched lots of websites to learn URL rewrite by using .htaccess, But didnt able to make them working in my server.
Place this in you .htaccess file
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-+/]+)$ ?type=$1
RewriteRule ^([a-zA-Z0-9-+/]+)/$ ?type=$1
Yes it is absolutly possible.
Your have to be sure your hostprovider has enable URL rewriting (I don't really remenber but I'm sur you can find help on Internet to verify that).
You have to create an ".htaccess" file at the root of your site.
Put this content in it :
tell the server to follow symbolic links :
Options +FollowSymlinks
activate the rewrite module :
RewriteEngine on
Rule for rewrite url
RewriteRule ^([a-z]+)$ /index.php?type=$1 [L]
Note this is just a qucik exemple you may want to look "url rewriting tutorial" on Google.
Please how can I rewrite
Could anybody please rewrite this url?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
to
http://localhost/display_news_cat/14/2
Thank you
Create an .htaccess file in the site directory and add the following lines
RewriteEngine on
RewriteRule ^display_news_cat/([\d]+)/([\d]+)$ display_news_cat.php?news_cat=$1&p=$2
Afaik, this is normally accomplished with Apache .htaccess file rewrite rules.
Is you case this would look something like:
RewriteEngine on
RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2
If this doesn't work, try checking your access logs to see what's happening.
there are different ways to archive this, and it takes only 1 minute to find this out yourself using google. you could:
use an .htacces file with rewrite-rules to let the apache do the rewriting
map everything on localhost/ to an index.php, read and parse the request-string "by hand" hand show the correct site
Also you can hold it in one script use GET to retrieve the values you wish and re-create the URL with that values. I don't know if it will help you..
Anyway a .httacess file will be much more useful for you.