将 cat-art.php 更改为 cat/art.php

发布于 2024-09-01 16:02:07 字数 582 浏览 3 评论 0原文

您好,我在更改网址时遇到问题。我有文件:cat-art.php(cat-类别,art-文章标题),我希望更好地访问它们:cat/art.php,所以我在 .htaccess 中编写了一些代码,但它不起作用。

RewriteCond %{REQUEST_URI} ^/([^-]+)/([^-]+).html$
RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.html [L]

请问某人能帮我吗?感谢您的帮助

编辑:

按照拉米所说进行了更改,它有效,但不是我想要的。它将cat-art.php更改为cat/art.php,我想更改为cat/art.html,当我更改它时它不起作用。

RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.php [L] - doesnt work
RewriteRule ^([^-]+)/([^-]+).php$ $1-$2.php [L] - works

EDIT2:它有效 - 浏览器问题 - 我删除了历史记录、cookie 等,现在它可以在 IE FF 和 Safari 中工作

Hi i got a problem with changing urls. I have files: cat-art.php (cat- category, art- title of an article) and i would like to have nicer access to them: cat/art.php so i wrote some code in .htaccess but it doesnt work.

RewriteCond %{REQUEST_URI} ^/([^-]+)/([^-]+).html$
RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.html [L]

Can sb help me please? Thanks for your help

EDIT:

Changed as rami said and it works but it isn't what i was looking for. it change cat-art.php into cat/art.php and i would like into cat/art.html when i changed it it didnt work.

RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.php [L] - doesnt work
RewriteRule ^([^-]+)/([^-]+).php$ $1-$2.php [L] - works

EDIT2: It works - problems with browser - i deleted history, cookies etc. and now it works in IE FF and Safari

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

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

发布评论

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

评论(1

萌无敌 2024-09-08 16:02:07

当然它不起作用 - 您正在重定向 .html 文件,而不是 .php ;-) 并且:在这种情况下,RewriteCond 语句是无用的。

RewriteRule ^([^-]+)/([^-]+).php$ $1-$2.php [L]

Of course it does not work - you are redirecting .html files, not .php ;-) And: the RewriteCond statement is useless in this case.

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