【发布时间】:2016-10-13 14:16:44
【问题描述】:
也许你可以帮我重写我的 URL(我从未使用过 .htacces 文件)。
示例: 我有一个这样的网址:http://localhost/index.php?s=example
我怎样才能找到这样的 URL:http://localhost/example?
也许你可以帮助我。
谢谢!
【问题讨论】:
也许你可以帮我重写我的 URL(我从未使用过 .htacces 文件)。
示例: 我有一个这样的网址:http://localhost/index.php?s=example
我怎样才能找到这样的 URL:http://localhost/example?
也许你可以帮助我。
谢谢!
【问题讨论】:
您可以在root/.htaccess中使用以下内容
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?s=$1 [NC,L]
此脚本将允许您使用干净的 url /foobar 访问 /index.php?s=foobar
【讨论】: