apache - How to do URL re-writing in PHP? -


I'm trying to implement URL rewriting in my PHP application. Can anyone share a step with the process of implementing URL rewriting in PHP and MySQL?

In my application, I want to implement the following URL rewriting, I want to redirect.

  1 Http://example.com/videos/play/google-io-2009-wave-intro 2. http://example.com/videos/play/203/google-io-2009-wave-intro  

to

  1 http://example.com/videos/play.php?title=google-io-2009-wave-intro 2. http: // Example.com/videos/play.php?id=203  

Please tell me how to implement the rewrite URL in any of the above ways.

One more thing that should be best according to the URL SEO, Management, Application Point of View is one of the following two types.

  1 Http://example.com/videos/play/google-io-2009-wave-intro 2. http://example.com/videos/play/203/google- Io-2009-wave-intro  

.

Usually this will not do anything more than enabling mod_rewrite module (you likely have enabled with your host already), and then adding an .htaccess file to your web directory once you do so , You can only after a few rows away. The above tutorials will take care of you.

Just for fun, here is a rewrite of an .htaccess file:

  # rewrite the URL # Turn on the rewrite on the installation directory, rewrite / RootDir / Protect applications and system files from being viewed #RewriteRule ^ (application | module | system) - [F, L] # Allow any file or directory that is directly available for displaying straight away% {REQUEST_FILENAME} Are you -f Rewrite% {REQUEST_FILENAME}! -d # index.php / RewriteRule to rewrite all other URLs. * Index.php / $ 0 [PT, L]  

What this will do and will take all the requests and channel them through the index.php file so if you are www.examplesite.com / Subjects / php, you can actually go to www.examplesite.com/index.php?a=subjects&b=php.

If you are attractive to these URLs, I encourage you to go one step further and check the MVC framework (model, view, controller). This essentially allows you to treat your website as a group of work:

www.mysite.com/jokes

  public function jokes ($ Page = 1) {# show Mocking page (on default 1 page)}  

Or, www.mysite.com/jokes/2

  public function Joke ($ page = 1) {# Show the joke of page 2 due to our separate URL}}  

Note how the first forward slash function calls, and all the parameters of that function A Follow to fill. It's really great, and make web-development very fun!


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -