问题
maybe you can help me to rewrite my URL (i never worked with a .htacces-file).
Example: I have a URL like this: http://localhost/index.php?s=example
How i can chance this URL like this: http://localhost/example ?
Maybe you can help me.
Thank you!
回答1:
You can use the following in root/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?s=$1 [NC,L]
This script will allow you to access /index.php?s=foobar
using the clean url /foobar
来源:https://stackoverflow.com/questions/37785058/htaccess-rewrite-url-for-my-website