如何使用.htaccess文件将目录(在本例中为/resume/
)重定向到文件(/Resume.pdf
)?我尝试了不同的重写方法,但不断获得重定向循环。这是因为与WordPress发生冲突吗?
这似乎不起作用:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^resume/ http://domain.com/Resume.pdf [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
答案 0 :(得分:0)
好的,我想出来了,这就是我的工作:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/resume$ [NC]
RewriteRule ^(.*)$ http://domain.com/Resume.pdf [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress