我只使用 html 启动了一个站点,将其切换到 php 以使我的生活更轻松,并在 .htaccess 中使用了以下代码以确保所有用户(可能已添加书签)仍能看到正确的页面:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R,NC]
现在,我正在新闻部分工作一个 wordpress 博客(在 /news 目录内),当我将下面的重写代码拍到我的 .htaccess 中时,我的 wordpress 目录之外的所有文件默认为 wordpresses 404 ,他们仍然在栏中有正确的地址,但没有信息。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
</IfModule>
任何人都可以帮助 .htaccess 的正确结构 - 我倾向于将片段用于特定任务而不是编写 htaccess 的东西。
谢谢