Solved

htaccess URL Rewrite

Posted on 2013-06-06
7
241 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 6

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now