我的网站 htaccess 需要短 URl

发布于 2024-11-25 10:53:44 字数 411 浏览 1 评论 0原文

我需要更改

http://localhost/engineering/management/administrator/modules/course/view.php

http://localhost/engineering/course_view.php

我尝试了以下重写

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^engineering/([.*])_([.*])\.php$  /engineering/management/administrator/modules/$1/$2.php

但它不影响网址。我认为代码有一些问题。

I need to change

http://localhost/engineering/management/administrator/modules/course/view.php

to

http://localhost/engineering/course_view.php

I tried the following rewriting

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^engineering/([.*])_([.*])\.php$  /engineering/management/administrator/modules/$1/$2.php

But it does not affect the url. I think the code has some problem.

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

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

发布评论

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

评论(2

铃予 2024-12-02 10:53:44

我们开始吧:

Options +FollowSymlinks
 RewriteEngine on
 RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/course/view.php

由于您位于 localhost 且位于工程文件夹内,因此您可以在规则中省略它。仅当您将 .htaccess 放入工程文件夹中时,此操作才有效。

http://localhost/engineering/course_view.php

谢谢,

纳吉姆

Here we go:

Options +FollowSymlinks
 RewriteEngine on
 RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/course/view.php

Since you are in localhost and inside the folder engineering, you can omit that in rule. This works only if you place the .htaccess inside the engineering folder.

http://localhost/engineering/course_view.php

Thanks,

Najeem

︶葆Ⅱㄣ 2024-12-02 10:53:44

只需从规则中删除 '[' ']' 即可。

RewriteRule ^/engineering/(.*)_(.*)\.php$  /engineering/management/administrator/modules/$1/$2.php

UPD
在替换模式的开头添加了“/”。

PS 抱歉,我自己无法检查这条规则。我的电脑上还没有安装apache。

Just delete '[' ']' from your rule.

RewriteRule ^/engineering/(.*)_(.*)\.php$  /engineering/management/administrator/modules/$1/$2.php

UPD
Added '/' at the beginnig of replace pattern.

P.S. Sorry, I can't check this rule myself. Haven't apache installed on my pc.

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