帮助写一个htaccesshtaccess

2023-09-02 09:45:19 作者:Destiny(宿命)

我想将所有的页面重定向到我的index.php,这样我就可以解析URL和处理剩下的一个htaccess文件。我只是不知道怎么写呢。

I'd like an htaccess file that would redirect all pages to my index.php so that I can then parse the url and handle the rest. I just don't know how to write it.

感谢

推荐答案

如果你谷歌周围,你会发现不同的方式去做。这是我做的(与Zend框架)的方式。

If you Google around, you'll find various way to do it. This the way I do it (same as Zend Framework).

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

希望它帮助。

Hope it helps.