Url Rewriting using .htaccess good example/sites in PHP.

This is a discussion on Url Rewriting using .htaccess good example/sites in PHP. within the PHP forums, part of the Web Development category; Hello, I am looking for good resource to learn URL Rewriting using .htaccess good examples/sites in PHP....
 
Members Login.
 

Please register HERE to be part of our Community

PHP » Current Topics
 

Popular Social Groups.
 
The active BRL users
cwp (web development)
Malaysia Member
Richest Members

Contest of the Day.
 
Contest # 8 (Longest Thread Contest)

Invite Your Friends...
 

Invite your contacts from social groups / email address book to Join BRL.
Information is transmitted over secure channel.
We don't store any information.


Sponsors.
 



BRL Webmaster Forum » Programming & Web Development » Web Development » PHP » Url Rewriting using .htaccess good example/sites in PHP.

PHP Discussion related to PHP web development, PHP coding. Tutorials, source code, tips and tricks related to PHP programming.

Reply
  #1 (permalink)  
Old September 10th, 2008, 03:36 AM
Jr. Member

developer's Avatar
Join Date: Dec 2006
Posts: 163
BRL$: 378.76
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 67
developer is on a distinguished road
Send a message via MSN to developer Send a message via Yahoo to developer Send a message via Skype™ to developer
Question Url Rewriting using .htaccess good example/sites in PHP.

Hello,

I am looking for good resource to learn URL Rewriting using .htaccess good examples/sites in PHP.
__________________
Web Developer
(
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
)


Jobs In !!! - Post Jobs, Hire Employees, Create Blogs and Earn Money.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old September 10th, 2008, 03:46 AM
Senior Member

smartzkool's Avatar
Join Date: Aug 2008
Location: India
Posts: 2,418
BRL$: 202.78
Thanks: 23
Thanked 74 Times in 74 Posts
Rep Power: 251
smartzkool is on a distinguished road
Default Re: Url Rewriting using .htaccess good example/sites in PHP.

Hello developer,

1)Rewriting product.php?id=12 to product-12.html
It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.
RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1

2) Rewriting product.php?id=12 to product/ipod-nano/12.html
SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.
RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2

3) Redirecting non
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
URL to
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
URL

If you type yahoo.com in browser it will be redirected to
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$
RewriteRule (.*)
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
Have you checked zorpia.com.If you type
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
in browser you can see my profile over there. If you want to do the same kind of redirection i.e
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
to
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
then you can add the following code to the .htaccess file.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1

5) Redirecting the domain to a new subfolder of inside public_html.
Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result,
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
point out to the files inside “new” folder.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.
RewriteCond %{REQUEST_URI} !^/new/
RewriteRule (.*) /new/$1



Source -
To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts.


- SmartzKool


Jobs In !!! - Post Jobs, Hire Employees, Create Blogs and Earn Money.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old September 25th, 2008, 09:04 AM
Jr. Member

developer's Avatar
Join Date: Dec 2006
Posts: 163
BRL$: 378.76
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 67
developer is on a distinguished road
Send a message via MSN to developer Send a message via Yahoo to developer Send a message via Skype™ to developer
Default Re: Url Rewriting using .htaccess good example/sites in PHP.

Hi SmartzKool,

Ya this are good example for learning url rewriting using .htaccess file.

Thanks.
__________________
Web Developer
(
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
)


Jobs In !!! - Post Jobs, Hire Employees, Create Blogs and Earn Money.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
.htaccess, example or sites, examples, good, php, php., rewriting, sites, url, url rewriting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
What are good PHP Books to get? Rss_Feeds PHP 0 September 6th, 2007 12:07 PM
PHP 4 end of life announcement brl_admin PHP 0 July 13th, 2007 07:51 AM
Good way of protecting PHP code Rss_Feeds PHP 0 July 9th, 2007 18:57 PM
PHP 5.2.2 and PHP 4.4.7 Released brl_admin PHP 0 July 9th, 2007 06:47 AM
PHP 5.2.1 and PHP 4.4.5 Released brl_admin PHP 0 July 9th, 2007 06:47 AM


 
Terms Of Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107