Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Mod rewrite: profile.php?id=1 to profile/1

Posted on 2008-11-10
Medium Priority
Last Modified: 2012-05-05
I want profile.php?id=1 to look like profile/1. Also, I wonder how I can get the id into a php-variable, as there will no longer be anything in $_GET.

What is the best solution?
Question by:husker475
LVL 27

Accepted Solution

caterham_www earned 2000 total points
ID: 22926466
First, change your html code into href="profile/1" (mod_rewrite cannot change html source code).
Use a rewriteRule in a .htaccess file to rewrite a request of profile/1 back to profile.php?id=1 (internal rewrite):
RewriteEngine on
RewriteRule ^profile/([0-9]+)/?$ /profile.php?id=$1 [L]

Open in new window


Author Closing Comment

ID: 31515289
Perfect, thank you so much.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

577 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