我需要改变
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
但不影响url。我认为代码有问题。
我们开始吧:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/course/view.php
由于您位于 localhost 且位于工程文件夹内,因此您可以在规则中省略它。仅当您将 .htaccess 放入工程文件夹中时,此操作才有效。
http://localhost/engineering/course_view.php
谢谢,
纳吉姆
只需从规则中删除 '[' ']' 即可。
RewriteRule ^/engineering/(.*)_(.*)\.php$ /engineering/management/administrator/modules/$1/$2.php
UPD 在替换模式的开头添加了“/”。
附注抱歉,我自己无法检查这条规则。我的电脑上还没有安装apache。
2011 年 7 月 22 日 5:19 rMX的用户头像 MX 1,0901616 银徽章2323 铜徽章 感谢您的回复,我删除了它,但它仍然不起作用 – AGK 评论于 2011 年 7 月 22 日 5:43 将 .htaccess 文件放入工程文件夹中 – AGK 评论于 2011 年 7 月 22 日 5:45 当我检查 url localhost/engineering/course_view.php 时“它显示 404 未找到页面错误” – AGK 评论于 2011 年 7 月 22 日 5:46 感谢您的编辑,但它不起作用,这是我现在的 htaccess 文件 – AGK 评论于 2011 年 7 月 22 日 6:27 选项 +FollowSymlinks RewriteRule 上的 RewriteEngine ^/engineering/(.)_(.).php$ /engineering/management/administrator/modules/$1/$2.php – AGK 评论于 2011 年 7 月 22 日