Apache .htaccess错误地重定向
我希望在调用Apache .htaccess错误地重定向,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我希望在调用domain.ext/sitemap.xml时打开domain.ext/sitemap.xml.php。这是我开始工作的地方 我的问题是浏览器重定向到php文件,我不希望这样,它应该一直说sitemap.xml # Catch sitemap RewriteCond %{REQUEST_URI} ^/sitemap.xml$ #RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*) http://%{HTTP_HOST}/sitem
domain.ext/sitemap.xml
时打开domain.ext/sitemap.xml.php
。这是我开始工作的地方
我的问题是浏览器重定向到php文件,我不希望这样,它应该一直说sitemap.xml
# Catch sitemap
RewriteCond %{REQUEST_URI} ^/sitemap.xml$
#RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) http://%{HTTP_HOST}/sitemap.xml.php [L]
## Internally rewrite extensionless file requests to .php files ##
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# test if sitemap
RewriteCond %{REQUEST_URI} !^/sitemap
# and if it does not exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# then add .php to get the actual filename
RewriteRule ^(.*)/? index.php?q=$1 [L]
谁能告诉我原因?从目标URI中删除
http://
,以启用内部重写:
# Catch sitemap
RewriteRule ^sitemap\.xml$ /sitemap.xml.php [L]
## Internally rewrite extensionless file requests to .php files ##
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# test if sitemap
RewriteCond %{REQUEST_URI} !^/sitemap
# and if it does not exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# then add .php to get the actual filename
RewriteRule ^(.+?)/?$ index.php?q=$1 [L]
PS:如果目标URI以http://
开头,则mod_rewrite
以R=302
状态重定向