[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2006, 01:52 PM   #1 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


mod_rewrite question

I want to make all my url's in the form "index.php?p=<name of page>&<additional info>" into "<name of page>.php?<additional info>"

I have figured out the regex to match all my pagess (i think)
Code:
index.php?p=[a-zA-Z0-9]{1,}&[a-zA-Z0-9&=]{1,}
How would I get that into mod_rewrite format?
Barrucadu is online now  
Old 11-02-2006, 12:00 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Erm lemme see if i can remember this right...

Code:
RewriteRule ^([a-zA-Z0-9]+)\.php?([a-zA-Z0-9&=]+)$ index.php?p=$1&catid=$1&$2 [L]
Thats how you said you wanted it. Although it might be easier if you just did:


Code:
RewriteRule ^(.*)\.php?(.*)$ index.php?p=$1&$2 [L]
Although then again if you did the & sign for <name of page>&<additional info> you would need a second variable.

Code:
RewriteRule ^(.*)\.php?(.*)$ index.php?p=$1&additionalinfo=$2 [L]
^^^
That is how i would do it. Be sure to enclose that rule in tags like:

Code:
<IfModule mod_rewrite.c>
and then closing tags like:

Code:
</IfModule>
__________________
-Beaver6813.com V5 Soon!
beaver6813 is offline  
Old 11-02-2006, 12:46 AM   #3 (permalink)
 
kleszcz's Avatar
 
Join Date: Jul 2006
Posts: 4,108
384.35 NP$ (Donate)

kleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatness

Marrow Donor Program Multiple Sclerosis
mod_rewrite enable "path/<name of page>/<additional info>.html" for your better search engine results right?
kleszcz is offline  
Old 11-02-2006, 08:30 AM   #4 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Yeah that would be better masking it as a html, but if he wants to keep it as a php file then fine

For example on one of my gaming sites i use mod_rewrite:

Code:
RewriteRule ^showcat/([0-9]+)/([0-9]+)/(.*)\.html$ index.php?action=showcat&catid=$1&parentid=$2 [L]
so if they do games/showcat/(catid)/(gameid)/(gamenamejustfordisplay).html

it will redirect it all to the php file. Very fun to do ^^
__________________
-Beaver6813.com V5 Soon!
beaver6813 is offline  
Closed Thread


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


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:13 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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