url restructure

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

url restructure

Post by nite4000 »

I need some help here guys i am doing some work for a friend and he wants me to restructure his url and what i mean is there is a link that go to this

http://www.domain.com/?a=details&lid=5
details being the page and lid being the id from the table

but he wants me to make it go to this
http://www.domain.com/sitetitle

title being from the table where the id is. but i cant figure how to remove the details part.

I can make it go to http://www.domain.com/?a=details&title=sitetitle but i would still have the ?a=details part.

anyone that can give me a shout let me know

Thanks
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: url restructure

Post by twinedev »

Try adding the following to (or create it) the .htaccess file in the root of your web directory:[text]RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.php?a=details&title=$1 [L][/text]
What it is doing: Any request made to the server, that is NOT a file that exists and is NOT a directory that exists, it will take you to index.php with the parameters you were able to work with.

-Greg
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: url restructure

Post by nite4000 »

that didnt work i got a internal error. I have never done this before. i have rea don it but still dont understand it
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: url restructure

Post by Pazuzu156 »

One thing is you need to edit the httpd.conf file for Apache if that is the server you are using. Look for:

#LoadModule rewrite_module modules/mod_rewrite.so

Remove the # save it and restart your server, you should be good to go.
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
Post Reply