将 cat-art.php 更改为 cat/art.php
您好,我在更改网址时遇到问题。我有文件: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然它不起作用 - 您正在重定向 .html 文件,而不是 .php ;-) 并且:在这种情况下,RewriteCond 语句是无用的。
Of course it does not work - you are redirecting .html files, not .php ;-) And: the RewriteCond statement is useless in this case.