Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2067 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

PHP & mod_rewrite Query

Thread title: PHP & mod_rewrite Query
Closed Thread    
    Thread tools Search this thread Display Modes  
10-03-2008, 08:55 AM
#1
Garyrae is offline Garyrae
Status: Request a custom title
Join date: Dec 2005
Location: Colchester, UK
Expertise:
Software:
 
Posts: 4,625
iTrader: 16 / 100%
 

Garyrae is on a distinguished road

Send a message via MSN to Garyrae Send a message via Skype™ to Garyrae

  Old  PHP & mod_rewrite Query

Quick question,
I have a form that once submitted goes to:
Code:
/search.php?query=keywords
How would I get the form to submit to:
Code:
/search/keywords
Any help would be greatly appreciated.

10-03-2008, 03:36 PM
#2
dynamic313 is offline dynamic313
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 50%
 

dynamic313 is on a distinguished road

Send a message via MSN to dynamic313

  Old

Originally Posted by -Gary View Post
Quick question,
I have a form that once submitted goes to:
Code:
/search.php?query=keywords
How would I get the form to submit to:
Code:
/search/keywords
Any help would be greatly appreciated.
somthing like this should do the job:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule search/(.*)/ search.php?query=$1
RewriteRule search/(.*) search.php?query=$1
May not be 100% perfect but im sure thats near enough correct or at least enough to trigger some one elses memory

10-03-2008, 04:02 PM
#3
Garyrae is offline Garyrae
Status: Request a custom title
Join date: Dec 2005
Location: Colchester, UK
Expertise:
Software:
 
Posts: 4,625
iTrader: 16 / 100%
 

Garyrae is on a distinguished road

Send a message via MSN to Garyrae Send a message via Skype™ to Garyrae

  Old

Aye that works for the mod_rewrite part; Cheers.

But, that's only if the user goes directly to:
Code:
http://www.domain.com/search/keywords
How do I get the form to submit directly to that URL?

10-10-2008, 09:49 PM
#4
iTony is offline iTony
iTony's Avatar
Status: I'm new around here
Join date: Aug 2008
Location:
Expertise:
Software:
 
Posts: 3
iTrader: 0 / 0%
 

iTony is on a distinguished road

  Old

that's a good question that I hope somebody answers, because I need to know too.

10-11-2008, 02:37 PM
#5
autonomouse is offline autonomouse
autonomouse's Avatar
Status: I'm new around here
Join date: Jun 2008
Location:
Expertise:
Software:
 
Posts: 21
iTrader: 0 / 0%
 

autonomouse is on a distinguished road

  Old

10-11-2008, 02:48 PM
#6
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Dynamic 313's rule should do the trick, here is how mod_rewrite works
1. User send request to pretty URL (www.site.com/pages/1/)
2. Apache find matching rule, if one matches it internally rewrites (www.site.com/page.php?id=1)
3. Apache sends output from ugly URL to browser without mentioning where on the server the code came from.

In short, you access the pretty URL and the server runs the "ugly" URL that it is written to.

Therefore when you directly type in the pretty URL it will do what you want, and unless you specifically restrict access to the ugly URL, that will also work.

Closed Thread    


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed