Change .php URL with id into .html

Given the PHP URL course.php?id=10 I want it to redirect to course.html and I want to use the id=10 on this page. How can I do this?

Answers


You can't cleanly rewrite the url and not include the variable somewhere. You'll need to do something like so:

RewriteRule ^([0-9]+)/([^.]+)\.html $2.php?id=$1 [L]

Which will work for http://example.com/10/course.html.


Create a .htaccess file and add the following:

RewriteEngine On
RewriteRule ^([^.]+)\.html$ $1.php [L]

Upload this to the root of your files (most of the time it's /var/www/ or /home/user/public_html/.


Need Your Help

handling submit event - jquery

javascript jquery

I have some javascript that I'm trying to retool using jQuery to learn the library better and I am running into what seems to be a very elementary problem.

Launch another app from myapp without url scheme - jailbreak users are able to, so how?

iphone xcode ios4 jailbreak

i'm trying to write a small application, a "launcher" app, that comes up when i plug my phone to power supply. Now there should be a 4x4 grid with my fav app i want to load. therefore no problem.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.