.htaccess文件,用于wordpress example.com/blog重定向到example.com

时间:2015-01-03 19:27:41

标签: wordpress .htaccess

我的www.tripfelt.com网站使用下面的.htaccess来处理漂亮的网址:

Options +FollowSymLinks

# enable rewrite engine
RewriteEngine On
RewriteRule ^blog - [L,NC]
RewriteRule ^robots.txt - [L]
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_URI} !^/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]

www.tripfelt.com/blog使用以下.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

但是,点击任何博客项目而不是打开博客故事,都会重定向到主站点。我有什么想法吗?

2 个答案:

答案 0 :(得分:0)

尝试将blog文件夹中的基础更改为/blog/,并删除路由规则中的前导斜杠:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# END WordPress

答案 1 :(得分:0)

解决

博客文件夹

  # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

  # END WordPress