我的.htaccess
文件有问题。 我最近搬到那是在一个子目录中的根路径论坛(IPB),所以我写了这个.htaccess
文件.htaccess移动论坛和SEO网址
Options +FollowSymLinks
RewriteEngine on
RewriteBase/
RewriteRule ^view/([0-9]+)/?$ index.php?view=$1 [NC,L]
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /forum/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ forum/index.php
而这个工作非常出色。 基本上,我想要指向论坛的旧网址,被重定向到论坛子目录。
但这是问题所在。 在根路径现在,有一个index.php文件,这将是新的网站,我想搜索引擎友好的URL,所以我写了这条线
RewriteRule ^view/([0-9]+)/?$ index.php?view=$1 [NC,L]
但这种规则不起作用。 像
www.domain.com/view/welcome/
每个请求重定向到一个404页的IPB论坛。
我也试过放一些RewriteCond,但结果是一样的, 每个涉及根路径中新index.php的url都会变成一个404页面。
编辑: 在/论坛/ 有此.htaccess
ErrorDocument 401 /401.shtml
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum
RewriteCond %{REQUEST_FILENAME} .*\.(jpeg|jpg|gif|png)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /public/404.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]
</IfModule>
还没干活G。我相信问题是我用来将请求重定向到/ forum /的规则,但我现在不能找到解决方案 – divby0
。我已经扩展了答案 – splash58
不,这不起作用。 – divby0