.htaccess重写我网站的URL

时间:2016-06-13 08:31:50

标签: .htaccess url-rewriting

也许你可以帮我改写我的网址(我从未使用过.htacces文件)。

实施例: 我有这样的网址:http://localhost/index.php?s=example

我如何能够像这样访问此网址:http://localhost/example

也许你可以帮助我。

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以在root/.htaccess

中使用以下内容
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?s=$1 [NC,L]

此脚本允许您使用干净网址/index.php?s=foobar

访问/foobar