|
Posted by Ed on 11/12/05 03:26
go@thescriptsmailer.com wrote:
> Can someone please tell me what URL rewriting is? I don't understand . . . a client is asking me to rewrite his URLs.
>
Hi there,
What your client is probably referring to is Apache's mod_rewrite
module. It is often used to rewrite 'static' URLs to dynamic ones,
which has several advantages; URLs are easier to remember, it makes
pages more search engine friendly, and I personally like the ability to
hide URL strings for security reasons.
Rewrite rules are generally written in an .htaccess file, see an example
below:
RewriteEngine on
RewriteRule ^fake_directory/?$ index.php?id=2 [NC]
Though the address bar in the browser will show
http://mydomain.com/fake_directory/, you really are serving
http://mydomain.com/index.php?id=2.
Something more dynamic (you can use regular expressions):
RewriteRule ^fake_directory/([a-zA-Z0-9]+)/?$ index.php?id=2&string=$1 [NC]
The above will rewrite
http://mydomain.com/fake_directory/{custom_string}/ to
http://mydomain.com/index.php?id=2&string={custom_string}
I am sure someone more knowledgeable will be able to provide you with a
better explanation - I have only just started learning it. You could
also search the web for 'mod_rewrite', there are quite a few good
tutorials around. I found
http://www.workingwith.me.uk/articles/scripting/mod_rewrite/ quite
helpful. I must warn you - mod_rewrite is addictive ;-)
Good luck,
Ed
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Navigation:
[Reply to this message]
|