mod_rewrite - 使business.php成为文件夹

发布于 2024-12-13 21:28:24 字数 622 浏览 0 评论 0原文

让 .htaccess (mod_rewrite) 工作起来非常困难 我的 .htaccess 文件中已经有这个用于友好 URL 的脚本 这很完美

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^article/(.*)/(.*)$ news_id.php?newsid=$1

但现在我想在主导航中隐藏我的文件扩展名...... ..so mypage.com/business.php 将变为 mypage.com/Business

我被告知添加 RewriteRule ^business$business.php [L]< /code>

...但它并没有减少它,谷歌已将我列入搜索黑名单,

我是否必须在 html/php 文件中的按钮中添加一些内容? ...这是按钮

我认为 php 文件没有连接到我的 .htaccess 但这不可能是因为 第一个重写规则有效

有什么建议吗?

Making .htaccess (mod_rewrite) work has been very difficult
I already have this script for friendly url in my .htaccess file
and that works perfect

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^article/(.*)/(.*)$ news_id.php?newsid=$1

But now I want to hide my file extension in the main navigation...
..so mypage.com/business.php will become mypage.com/Business

I was told to add RewriteRule ^business$ business.php [L]

...but it doesn´t cut it and Google has blacklisted me for searching

Could it be I have to add something to the button in my html/php file?
...this is the button
<li class="nav-business"><a href="business.php"></a></li>

I think the php-file doesn´t connect to my .htaccess but that can´t be because
this first Rewrite rule works

Any suggestions?

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

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

发布评论

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

评论(1

终止放荡 2024-12-20 21:28:24

您可能想尝试这样的操作。要从 PHP 文件(例如 yoursite.com/wallpaper.php 到 yoursite.com/wallpaper)中删除 .php 扩展名,您必须在 .htaccess 文件中添加以下代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

You might want to try something like this.To remove the .php extension from a PHP file for example yoursite.com/wallpaper.php to yoursite.com/wallpaper you have to add the following code inside the .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文