Jump to content

url shortening


Craig Hopson
 Share

Recommended Posts

hi guys how can i get

http://my-site.com/index.php?x=menu

to

http://my-site.com/menu

i have a site running already witch i the config file it has this to change how its displayed in the url bar,

$ubase = $uhome.'/index.php?x=';$ubase = $uhome.'/';

i've looked through the code but cant figure out how they did it Thanks

Link to comment
Share on other sites

you need to use url rewriting. you can google it.

Link to comment
Share on other sites

ok i tried thisRewriting yoursite.com/user.php?username=xyz to yoursite.com/xyzHave you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.

[color="#800000"]RewriteEngine OnRewriteRule ^([a-zA-Z0-9_-]+)$ index.php?x=$1RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?x=$1[/color]

but it didnt work

Link to comment
Share on other sites

First thing is to make sure that the file is called ".htaccess" which starts with a dot. Be sure that your server is running Apache and that mod_rewrite is enabled.

  • Like 1
Link to comment
Share on other sites

$1 is the match between the first set of parenthesis in a regular expression. You would need to study regular expressions to understand it better. This can't be done with PHP because the PHP file to be loaded has to be resolved from the URL. You'll have to search for an HTaccess alternative for your server software (if it exists)

Link to comment
Share on other sites

the RewriteRule does work on my server i just dont know the correct syntax i'm googling it as we speak but not making much sence i found this http://www.cheatography.com/davechild/cheat-sheets/mod-rewrite/ i maybe asking the wrong questions here but i have index.php?x=menu1, index.php?x=menu2, index.php?x=menu3, ect would mod-rewrite be able to change it to my-site.com/menu1, my-site.com/menu2, my-site.com/menu3,or am i wasting my time?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...