Link to home
Start Free TrialLog in
Avatar of bradley525
bradley525

asked on

htaccess URL Rewrite

I need to make my URL clean so that they look something like

http://www.mysite.com/new/about-us

is equal to

http://www.mysite.com//new/page.php?id=about-us

not really sure how to do this..

thanks
Avatar of kaufmed
kaufmed
Flag of United States of America image

Put "http://www.mysite.com/new/about-us" in your page(s). Then create a rewrite rule in your.htaccess to do the transformation:

RewriteRule ^new/([^/]+)$ new/page.php?id=$1

Open in new window

Avatar of bradley525
bradley525

ASKER

I added the htaccess file but I get a 404 error using

http://www.mysite.com/new/about-us
Do you have mod_rewrite enabled, and in which .htaccess file did you place the rule?
it has to be enabled in apache. Are you using a control panel? What level of access do you have to your server?
ASKER CERTIFIED SOLUTION
Avatar of bradley525
bradley525

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
got it working, since I am working in the folder "new" I do not need the "new/" in the code above, i just used


RewriteEngine On 
RewriteRule ^new/([^/]+)$ page.php?id=$1

Open in new window

This works perfect if you are in the root folder, if not just remove the "new/" and it will work...thanks