url changer htaccess config [复制]

I am having a problem here, does anybody know How to change my url from

http://localhost/myProfile.php?id=1

to

http://localhost/myProfile/1
</div>

Try this:

Options +FollowSymlinks
RewriteEngine on
AddDefaultCharset UTF-8 

RewriteCond %{REQUEST_URI} myProfile\.php
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ [NC]
RewriteRule ^(.*)$ /myProfile/%1 [NC,L]

Note: The [0-9]+ is a regex for accepting numbers between 0 and 9. The + means that there can be more than one of them. You can use another regex if you wish like [A-F0-9]{32} for example which accepts letters A-F, numbers 0-9 and there can be a total of 32 characters. You can tweek it to suit your needs. Keep in mind that if the conditions are not met the RewriteRule will not happen.

Try this

RewriteEngine On


RewriteRule ^([a-zA-Z0-9_-]+)$ myprofile.php?user=$1

RewriteRule ^([a-zA-Z0-9_-]+)/$ myprofile.php?user=$1