.htaccess 创建搜索引擎友好的 URL

发布于 2024-12-14 03:00:44 字数 476 浏览 0 评论 0原文

我正在寻找一种方法来摆脱我的文件中的 .php 扩展名,我刚刚得到了一个带有 index.php 和 map.php 的静态网站,

我已经尝试了很多不同的教程,但没有任何效果,我只想要以下内容。

http://example.co.uk/map.php becomes http://example.co.uk/map/

你能用静态文件来做到这一点吗

http://example.co.uk/index.php becomes http://example.co.uk/

?我尝试了很多不同的选项,但没有一个对我有用。

我已经尝试过了。

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/(.*)/$ map.php

请提供任何帮助。

I am looking for a way to get rid off the .php extension from my file i have just got a static website with index.php and map.php

I have tried lots of different tutorials but none work i just want the following.

http://example.co.uk/map.php becomes http://example.co.uk/map/

and

http://example.co.uk/index.php becomes http://example.co.uk/

Can you do this with a static file i have tried so many different options and none have worked for me.

i have tried this.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^map/(.*)/$ map.php

Any help please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

给妤﹃绝世温柔 2024-12-21 03:00:44

试试这个

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^map/?$ map.php [NC,QSA,L]

RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC]
RewriteRule (.*) http://www.domain.com/ [R=301,L]

# if you have more than one file like map, you can use this
# this will redirect everything to .php like: test/ => test.php
# RewriteRule ^([a-z0-9_\-]+)/?$ $1.php [NC,QSA,L]

Try this

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^map/?$ map.php [NC,QSA,L]

RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC]
RewriteRule (.*) http://www.domain.com/ [R=301,L]

# if you have more than one file like map, you can use this
# this will redirect everything to .php like: test/ => test.php
# RewriteRule ^([a-z0-9_\-]+)/?$ $1.php [NC,QSA,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文