2

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.

Tero Kilkanen
  • 38,887

4 Answers4

0

You can try with the below rules.

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

Or you could try

RewriteRule ^(.*) /$1/? [L,R=301]

I'm no redirect expert, but I think the question mark at the end cuts off all parameters.

0

If you are not rewriting anything else just use:

FallBackResource /send.php

and parse the PATHINFO

Unbeliever
  • 2,416
0

If you want to parse out the parameter to use it as file/directory you should try this:

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