【发布时间】:2015-12-30 09:40:07
【问题描述】:
在哪里添加重定向?
基于此页面: http://dvlancer.com/67-redirect-pages-with-html-suffix.html
当关闭 html 后缀时,我应该使用这个:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
只是将 .htaccess 放在上面(在 public_html 文件夹中)没有任何影响:
应该把它放在 htaccess.txt 中吗?这似乎是一个应该包含自定义内容的部分?
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
## End - Custom redirects
【问题讨论】:
-
mod_rewrite开启了吗? -
@hjpotter92 在htaccess中关闭,但在.htaccess.txt中开启
标签: apache .htaccess mod-rewrite joomla url-redirection