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 1613 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Mod rewrite

Thread title: Mod rewrite
Closed Thread    
    Thread tools Search this thread Display Modes  
08-16-2006, 10:42 PM
#1
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old  Mod rewrite

I'm looking to do some mod rewrite but haven't a clue..
I have something that is currently performing a GET, so http://mydomain.com/index.php?id=1 brings up database entry one.

I want that to be http://mydomain.com/1 or http://mydomain.com/1/

Is this possible? and how?

Regards,

08-16-2006, 11:11 PM
#2
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

RewriteEngine on
RewriteRule ^([0-9]+) index.php?id=$1 [L]

This could be wrong, as this is the first time I've actually written a mod_rewrite rule.

08-16-2006, 11:31 PM
#3
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

RewriteEngine on
RewriteRule ^(.+)/$ index.php?id=$1 [L]

Seems to work good now, thanks for checking around though!

08-16-2006, 11:42 PM
#4
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

however, i can't get the url to work as mydomain.com/123 aswell as mydomain.com/123/

edit, used yours and it works LOL!

Regards & thanks

08-17-2006, 12:27 AM
#5
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

lol, I'm suprised mine worked... I should start researching more about mod_rewrite and do alot more of it. :P

08-18-2006, 08:05 PM
#6
Woolf is offline Woolf
Status: I'm new around here
Join date: Oct 2005
Location:
Expertise:
Software:
 
Posts: 16
iTrader: 0 / 0%
 

Woolf is on a distinguished road

Send a message via AIM to Woolf Send a message via MSN to Woolf

  Old

Originally Posted by Jeff Andersen
however, i can't get the url to work as mydomain.com/123 aswell as mydomain.com/123/

edit, used yours and it works LOL!

Regards & thanks
Use the same rule you're currently using, only add a question mark to it:
RewriteEngine on
RewriteRule ^(.+)/?$ index.php?id=$1 [L]
The question mark essentially tells the script to, for example, display the index.php?id=pagehere page for http://mydomain.com/pagehere or http://mydomain.com/pagehere/. I do believe that is what you are looking for. If not, let me know.

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