Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like all the URLs of the following format:

mysite.com/xyz

to display:

mysite.com/show.php?keyword=xyz

How can I do this?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

it should work if you put this in .htaccess (given that mod_rewrite has been enabled on your webserver and you have the right to use it):

RewriteEngine On
RewriteRule ^/xyz$ /show.php?keyword=xyz [R=302,L]
share|improve this answer
    
Err, I meant xyz as a variable, not literally "xyz". Does this work for a that? –  Brandon Apr 22 '12 at 22:22
    
Oh, I see. Is it just a regular expression? –  Brandon Apr 22 '12 at 22:30
    
Would RewriteRule ^/([a-zA-Z]*)$ /show.php?keyword=$1 [R=302,L] work? –  Brandon Apr 22 '12 at 22:30
1  
Yes, you could do that, you should just care that you don't create a loop. If the catching part also matches show.php you will be bricked. –  daudo Apr 24 '12 at 8:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.