.htaccess 重写我网站的 URL [英] .htaccess rewrite URL for my website

查看:44
本文介绍了.htaccess 重写我网站的 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许你可以帮我重写我的 URL(我从来没有使用过 .htacces 文件).

maybe you can help me to rewrite my URL (i never worked with a .htacces-file).

示例:我有一个这样的 URL:http://localhost/index.php?s=example

Example: I have a URL like this: http://localhost/index.php?s=example

我怎么可能像这样使用这个 URL:http://localhost/example?

How i can chance this URL like this: http://localhost/example ?

也许你能帮我.

谢谢!

推荐答案

您可以在 root/.htaccess

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

此脚本将允许您使用干净的 url /foobar

This script will allow you to access /index.php?s=foobar using the clean url /foobar

这篇关于.htaccess 重写我网站的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆