Php – rewrite URL in htaccess and remove everything but parameter

.htaccessmod-rewritePHPrewrite

Is it possible to turn this URL:

example.com/send.php?url=google.com&name=&submit=submit

Into this URL:

example.com/google.com

When I try I just keep getting 404 or 500 errors and it's frustrating.

Here's a few thing's I've tried.

RewriteRule ^([^/]*)$ /send.php?url=$1&name=&submit=submit [NC,L]
RewriteRule ^([-\w\.]*)$ /send.php?url=$1&name=&submit=submit [NC,L]
RewriteRule ^(.*)$ /send.php?url=$1&name=&submit=submit [NC,L]

If it's not possible then please could you tell me why it's not. I'm rather new to mod_rewrite and want to learn.

Best Answer

You can try with the below rules.

RewriteCond %{REQUEST_URI} !send.php
RewriteRule ^([-\w\.])$ /send.php?url=$1&name=&submit=submit [NC,L]