URL Rewriting - PHP + Apache
I wanna turn PHP dynamic URLs into static URLs. For example, I want URLs like
http://www.example.com/bo开发者_如何学Pythonok.php?title=twilight to become http://www.example.com/book/twilight
and http://www.example.com/writer.php?name=meyers to become http://www.example.com/writer/meyers
When it's done, will my form validation on the site change?
My URL rewriting needs might not be much too complicated.
I'm developing it locally using XAMPP, Apache and MySql. Later I'll put it online.
How do I do that? Is this kind of URL rewriting technique the most adviced for SEO?
You would use mod_rewrite for that. If you do a bit of searching on here for that, you'll likely find lots of other questions about how to create mod_rewrite rules similar to what you want to do.
Yep. U need to use mod_rewrite. Also do a search for .ht_access files. You can put your rewrite directives in .ht_access files and drop them in to whatever directory on your server where you want them to take effect.
For the type of rewrite you want this rule generator should be of use to you:
http://www.generateit.net/mod-rewrite/
And yes the URL you're trying to achieve is seo friendly.
You can use a .htaccess file (or better apache.conf) to forward all requests to index.php with mod_rewrite:
Options +FollowSymLinks
IndexIgnore */*
<ifmodule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</ifmodule>
There you can use $_SERVER['REQUEST_URI']
to interpret the request.
精彩评论