Craig Hopson Posted May 21, 2012 Share Posted May 21, 2012 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 More sharing options...
birbal Posted May 21, 2012 Share Posted May 21, 2012 you need to use url rewriting. you can google it. Link to comment Share on other sites More sharing options...
Craig Hopson Posted May 22, 2012 Author Share Posted May 22, 2012 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 More sharing options...
Ingolme Posted May 22, 2012 Share Posted May 22, 2012 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. 1 Link to comment Share on other sites More sharing options...
Craig Hopson Posted May 22, 2012 Author Share Posted May 22, 2012 (edited) mine is LiteSpeed V5.5 can it still be done or can it be done with PHPalso where does the value $1 come from? Edited May 22, 2012 by Craig Hopson Link to comment Share on other sites More sharing options...
Ingolme Posted May 22, 2012 Share Posted May 22, 2012 $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 More sharing options...
Craig Hopson Posted May 22, 2012 Author Share Posted May 22, 2012 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 More sharing options...
Ingolme Posted May 22, 2012 Share Posted May 22, 2012 Look at http://www.regular-expressions.infoThey have a quick tutorial, and a more in-depth one. Even the quick one is a bit long, so you better be in for a lot of reading. Link to comment Share on other sites More sharing options...
Craig Hopson Posted May 22, 2012 Author Share Posted May 22, 2012 ok i read the full tutorial and i didnt understand much of it at all Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now