-1

I need to rewrite a URL so when this is called http://localhost/asset/?id=n the internal 'expression' should look like the following http://localhost/asset.php/?id=n (where n is a integer).

I have tried

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^asset/?id=([0-9]+)$ asset.php?id=$1

but it simply does not work due to ?id= not acting like a string. I'm very new to RewriteRule and Apache config itself so any help would really be appreciated.

Thanks,

1 Answers1

0

You can try this.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ asset.php?/$1 [QSA,PT,L]
</IfModule>

Save this as a file .htaccess and place it in the root directory.

Lopes Wang
  • 34
  • 2