的.htaccess URL重写(sitemap.xml的为sitemap.php) [英] .htaccess URL re-write (sitemap.xml to sitemap.php)

查看:225
本文介绍了的.htaccess URL重写(sitemap.xml的为sitemap.php)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我目前的.htaccess文件。我想补充的另一个条件/规则的,如果对sitemap.xml的一个请求,sitemap.php供应代替。请帮助:)

 选项+了FollowSymLinks

< IfModule mod_rewrite.c>

   RewriteEngine叙述上

   的RewriteBase /

   的RewriteCond%{} REQUEST_FILENAME!-f
   的RewriteCond%{} REQUEST_FILENAME!-d

   重写规则^(。*)$的index.php?文件名= $ 1 [L,QSA]

< / IfModule>
 

解决方案

您可以明确地做到这一点:

 选项+了FollowSymLinks

< IfModule mod_rewrite.c>
  RewriteEngine叙述上

  的RewriteBase /

  重写规则^ sitemap.xml的$ sitemap.php [L]

  的RewriteCond%{} REQUEST_FILENAME!-f
  的RewriteCond%{} REQUEST_FILENAME!-d
  重写规则^(。*)$的index.php?文件名= $ 1 [L,QSA]
< / IfModule>
 

您很可能会遇到一些问题这样做虽然...你应该创建排除蜘蛛,使他们仍然收到sitemap.xml的

below is my current .htaccess file. I would like to add another condition/rule where if a request for sitemap.xml is made, sitemap.php is served instead. Please help : )

Options +FollowSymLinks

<IfModule mod_rewrite.c>

   RewriteEngine On

   RewriteBase /

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d

   RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]

</IfModule>

解决方案

You could do it explicitly:

Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteBase /

  RewriteRule ^sitemap.xml$ sitemap.php [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]
</IfModule>

You'll likely run into problems doing this though... You should create exclusions for spiders so they still receive the sitemap.xml

这篇关于的.htaccess URL重写(sitemap.xml的为sitemap.php)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆