我需要将以下页面重定向到他们的.php版本。
http://www.kgolf360.com/about
http://www.kgolf360.com/news
http://www.kgolf360.com/junior-performance-programs
http://www.kgolf360.com/before-after
http://www.kgolf360.com/book-lesson
http://www.kgolf360.com/family-performance-programs
http://www.kgolf360.com/technology
http://www.kgolf360.com/adult-performance-programs
例如,我需要重定向
http://www.kgolf360.com/about
到
http://www.kgolf360.com/about.php
等。
我所做的是通过添加以下内容来修改我的.htaccess文件:
Redirect 301 /about http://www.kgolf360.com/about.php
但它给了我404错误。如果你转到http://www.kgolf360.com/about
,你可以看到它我是否可能需要配置其他内容才能使其正常工作?如果是这样,我需要做什么才能正确地重定向URL?
这是我的.htaccess文件的内容:
rewriteengine on
rewritecond %{HTTP_HOST} ^www.kgolf360.com$ [OR]
rewritecond %{HTTP_HOST} ^kgolf360.com$
rewriterule ^about$ "http\:\/\/kgolf360\.com\/about\.php" [R=301,L] #5682a68c22ecf
rewritecond %{HTTP_HOST} ^kgolf360.com$
rewriterule ^(.*)$ "http\:\/\/www\.kgolf360\.com\/$1" [R=301,L] #567eeb84dcae2
# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
# But *only if they exist*, otherwise it will report the usual 404 error.
Options +FollowSymLinks
# Redirect to HTML if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.html
# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewritecond %{REQUEST_FILENAME}.html -f
rewriterule ^(.+)$ $1.html [L,QSA]
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewritecond %{REQUEST_FILENAME}.php -f
rewriterule ^(.+)$ $1.php [L,QSA]
#Redirect all non-php URLs to their php versions
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
你们现在看到我现有的内容有什么问题吗?
答案 0 :(得分:3)
由于您使用的是Godaddy,因此您需要使用Options +MultiViews
。所以试试这段代码:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]