mod_rewrite

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

mod_rewrite

Post by s.dot »

Man, I have played around with this thing for a couple of hours now. Apaches description seems much too complex for me to comprehend at the moment, and googling turns up specific tutorials that don't seem to match my needs. Could someone please show me how to do this:

turn

http://www.domain.com/page.php?var=something

into

http://www.domain.com/something
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your sure you don't want the second to rewrite to the first?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Yeah that's what I mean.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

my feeble attempt to write this myself goes as follows:

Code: Select all

ReWriteEngine on
ReWriteRule ^(\w+)(/)?$ showme.php?u=$1 [R]
Currently this doesn't do much. It gives me a page not found error.

What I'm attempting to match is any character A-Z a-z 0-9 underscores and hyphens (max 25 characters)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to Misc.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

OK. So I came up with this rule (despite my many attempts for help :P). I guess once you're after something, eventually you'll find the answer.

Code: Select all

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)(/)?$ page.php?u=$1
This works great. Does anyone see any problems with it? Like would a normal page ever be caught by this regex?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

test it, young lad. You're gettin' there jus' fine, me boy. A hearty yar to ya!
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Maybe you could explain what was he trying to do?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

pilau wrote:Maybe you could explain what was he trying to do?
explains it pretty well in his original post... :P
Post Reply