[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

htaccess URL Rewrite

Posted on 2013-06-06
7
Medium Priority
?
253 Views
Last Modified: 2013-06-16
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
0
Comment
Question by:bradley525
  • 4
  • 2
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39225945
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

0
 

Author Comment

by:bradley525
ID: 39225972
I added the htaccess file but I get a 404 error using

http://www.mysite.com/new/about-us
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39225984
Do you have mod_rewrite enabled, and in which .htaccess file did you place the rule?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 7

Expert Comment

by:Robert Saylor
ID: 39232375
it has to be enabled in apache. Are you using a control panel? What level of access do you have to your server?
0
 

Accepted Solution

by:
bradley525 earned 0 total points
ID: 39237381
Yes I am useing control panel, the .htaccess file is

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

Open in new window


it is not doing anything though.
0
 

Author Comment

by:bradley525
ID: 39237421
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

0
 

Author Closing Comment

by:bradley525
ID: 39251030
This works perfect if you are in the root folder, if not just remove the "new/" and it will work...thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question