.htaccess 重写

发布于 2024-09-30 18:18:07 字数 375 浏览 1 评论 0原文

有人可以帮我编写仅使用一个文件的代码吗?

例如,

domain.com/
domain.com/hello/world/
domain.com/help.php

上述所有内容都应该加载

domain.com/index.php

我已经在家里完成了此操作,但我不记得它并且我无权访问该代码。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

我认为以下内容是我记得的但不起作用。

can someone help me with the code to use only one file.

e.g.

domain.com/
domain.com/hello/world/
domain.com/help.php

all the above should load

domain.com/index.php

I have done this at home, but i cnt remember it and i dont have access to that code.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

i think the following is something that i remember but it aint working.

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

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

发布评论

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

评论(1

戒ㄋ 2024-10-07 18:18:07

检查重写模块是否工作

cat  /etc/apache2/mods-available/rewrite.load 
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

,这个来自 zend 框架,我认为应该比一般使用的更好

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

check if rewrite module is working

cat  /etc/apache2/mods-available/rewrite.load 
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

this one is from zend framework, I think should be better than general used one

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