需要将website.com/2015/03/post-title
等所有博客链接重定向到website.com/blog/2015/03/post-title
。到目前为止,我没有使用任何工作 - 既不重定向也不重定向。
发生了什么事情是网站从Wordpress重新设计到Joomla,所以在网站的根目录上有一个Joomla .htaccess文件,但博客仍然在wordpress上,所以在{{1上安装了worpdress有自己的.htaccess。
这是root .htaccess内容:
/blog
Blog .htacess内容:
##### RewriteEngine enabled - BEGIN
RewriteEngine On
RewriteRule ^(\d{4}/\d{2}/.+)$ /blog/$1 [L,NC,R=301]
##### RewriteEngine enabled - END
##### Custom Rules (Top of File) -- BEGIN
Redirect 301 /practice-areas/construction-law /practice-areas/civil-litigation
Redirect 301 /practice-areas/family-law /practice-areas/civil-litigation
##### Custom Rules (Top of File) -- END
##### File execution order -- BEGIN
DirectoryIndex index.php index.html
##### File execution order -- END
##### No directory listings -- BEGIN
IndexIgnore *
Options -Indexes
##### No directory listings -- END
##### Redirect index.php to / -- BEGIN
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^index\.php$ http%2:/// [R=301,L]
##### Redirect index.php to / -- END
##### Redirect www to non-www -- BEGIN
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
##### Redirect www to non-www -- END
##### Rewrite rules to block out some common exploits -- BEGIN
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_(en|de)code\(.*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
##### Rewrite rules to block out some common exploits -- END
##### File injection protection -- BEGIN
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC]
RewriteRule .* - [F]
##### File injection protection -- END
##### Advanced server protection rules exceptions -- BEGIN
RewriteRule ^administrator\/components\/com_akeeba\/restore\.php$ - [L]
RewriteRule ^administrator\/components\/com_admintools\/restore\.php$ - [L]
RewriteRule ^administrator\/components\/com_joomlaupdate\/restore\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/install\/index\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/fields\/combo\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/fields\/modals\/typography\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/typography\/typography\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/typography\/typography2\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jtreelink\/dialogs\/initialize\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jtreelink\/dialogs\/links\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jfilebrowser\/core\/connector\/php\/connector\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/index\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/phpthumb\/phpThumb\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_details\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_tiles\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_content\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_list\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_images_large\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/view_images_small\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/file_specs\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/swfupload\/upload\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/actions\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/process\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jckexplorer\/close\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/ImageManager\/manager\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/ImageManager\/images\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/ImageManager\/thumbs\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/ImageManager\/editor\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/ImageManager\/editorFrame\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jlink\/dialogs\/suggest\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jautosave\/autosave\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/texttranslate\/gotranslate\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/atdckeditor\/proxy\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/aspell\/spellerpages\/server\-scripts\/spellchecker\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jallvideos\/dialogs\/event\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jallvideos\/dialogs\/updatemediatype\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jsimpleimagegallery\/dialogs\/event\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/articlepreview\/index\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/GeSHi\/dialogs\/dialog\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/jdoclink\/params\.config$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/imageresize\/imageresize\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/imageresize\/simpleimage\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/htmlfilters\/ajaxfilters\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/htmlfilters\/helper\/helper\.php$ - [L]
RewriteRule ^plugins\/editors\/jckeditor\/plugins\/uicolor\/dialogs\/uicolor\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !(\.php)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^plugins\/editors\/jckeditor\/install/ - [L]
RewriteRule ^templates\/your_template_name_here/ - [L]
##### Advanced server protection rules exceptions -- END
##### Advanced server protection -- BEGIN
RewriteCond %{QUERY_STRING} \=PHP[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12} [NC]
RewriteRule .* - [F]
## Disallow access to htaccess.txt, php.ini and configuration.php-dist
RewriteRule ^(htaccess\.txt|configuration\.php-dist|php\.ini)$ - [F]
##### Advanced server protection -- END
##### Joomla! core SEF Section -- BEGIN
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
##### Joomla! core SEF Section -- END
答案 0 :(得分:1)
将此规则作为第一条规则插入根目录中的RewriteEngine
行下方.htaccess:
RewriteRule ^(\d{4}/\d{2}/.+)$ /blog/$1 [L,NC,R=301]