NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page mod_rewrite question

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2006, 02:52 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
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 offline  
Old 11-02-2006, 01:00 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
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:
????: NamePros.com http://www.namepros.com/programming/253280-mod_rewrite-question.html

Code:
</IfModule>
beaver6813 is offline  
Old 11-02-2006, 01:46 AM   #3 (permalink)
 
kleszcz's Avatar
Join Date: Jul 2006
Posts: 4,607
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, 09:30 AM   #4 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
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
????: NamePros.com http://www.namepros.com/showthread.php?t=253280

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 is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:22 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger