通过.htaccess

时间:2017-09-09 06:33:04

标签: apache .htaccess redirect mod-rewrite

我有一个像www.example.com的网站,它有一些子目录vol1,vol2 ,, vol3,..... vol20。

我正面临通过.htaccess重定向未找到子目录链接到主页的问题。

假设我们搜索/去找任何未找到的网址

www.example.com/vol1/05.pdf
www.example.com/vol13/01-39.pdf
www.example.com/vol3/klsdk

然后它不会重定向到主页。我在htaccess中试过以下代码

     # Directs all EE web requests through the site index file
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
        RewriteRule ^(.*)$ /index.php/$1 [L]

Options +Indexes
IndexOptions +FancyIndexing

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC]

0 个答案:

没有答案