我想将blog.byperte.com/blog/article
重定向到blog.byperte.com/article
。该博客建立在Anchor CMS上,并具有以下.htaccess文件:
Options -indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
答案 0 :(得分:1)
要从网址中删除文件目录,请在.htaccess
:
RewriteEngine On
RewriteRule ^blog/(.*)$ /$1 [L,R=301]
确保在测试之前清除缓存。