我需要將以下頁面重定向到它們的.php版本。.htaccess不會重定向到.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]
難道你們看到我現在在FLE內容有任何問題?
您是否啓用了Apache的mod_alias?如果不是的話,'Redirect'指令將被忽略,並且/ about將返回一個404. – BareNakedCoder
也會檢查mod_rewrite是否被啓用並且你的服務器被配置爲使用它。這聽起來很愚蠢,但這多次是問題的根源。 – Gogol
這可能也有幫助http://stackoverflow.com/questions/17868819/apache-mod-rewrite-not-working-with-htaccess-file – Gogol