简体   繁体   中英

Rewrite flat url to parameter

I read quite a lot of posts on this, but nothing I could make work (or understand) so far. Let me apologize beforehand for asking something that might seems already answered.

I have personalized URLs ( fx. http://www.somedomain.com/someword ) which I need to turn into http://www.somedomain.com/test.php?name=someword

The parameter (someword) is based on a persons name, meaning there's no file-ending (like .html)

I tried a number of rewrites with htaccess, but no matter what, I get 'Internal server error', for example:

RewriteEngine On
RewriteRule   ^(.+)$   test.php?name=$1   [L]

Any help is appreciated.

Cheers

Hans

Your rule is looping since .+ matches URI after rewriting also.

Try this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule   ^(.+)$   test.php?name=$1 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM