English 中文(简体)
重写规则. *$ index.php [NC,L]
原标题:RewriteRule ^.*$ index.php [NC,L]

我试图将不存在的网页 重新定位到我的索引.php。

我用此数据创建了一个与索引.php相同的文件夹中的.htaccess 文件 。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR]
Rewritecond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Im 使用 Wampserver 和 httpd.conf 设置为 apache 服务器的 httpd.conf

全部允许覆盖

But still when I try to enter a non existent webpage I get the 404 error. Any idea?

EDIT. By the way, I ve seen this post HERE And tried the stuff held there, but it didn t work for me.

问题回答

你为什么不使用错误文档指令?

ErrorDocument 404 index.php

简单得多 管理费也少得多

如果您坚持使用 mod_ rewrite, 您可以使用 De Morgan 法律, 而不关心该页面存在时的情况: 它会正常使用, 您不需要使用明确的 Rewrite Rules $ *. * $ 。

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

说到这里,我认为你张贴的片段应该有效。我一点也不熟悉Wampserver, 但你似乎必须明白 "http://www.shariff.org/how-to-enable-enable-htaccess- in-wamp-server.html" rel=“nofollow”=“nofollow”=“nofollow”, 你这样做了吗?

此外,将不存在的页面改到索引.php,而没有向机器人或用户说明该页面不存在,这不是一个好主意。 与有效页面链接的错误页面将是一个更好的选择。





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签