阿帕奇:问题重定向 [英] Apache: Problems with redirects
问题描述
我的下一个规则,我应该能够访问该网址,没有任何问题:
I have the next rules, and I should be able to access to this URLs without any problem:
domain.com/robots.txt
- 我应该重定向到 - > domain.com/sitemapHT/robots.txt
现在的robots.txt拥有XML的文件,其中确实为网站的不同部分的写网站地图网站地图的索引。例如: domain.com/sitemapHT/sitemap_anuciantes.xml
domain.com/robots.txt
- should redirect me to -> domain.com/sitemapHT/robots.txt
now robots.txt has an index of xmls files, where does the sitemaps for different sections of the site write its sitemap. For example: domain.com/sitemapHT/sitemap_anuciantes.xml
在当前的规则(下)当我试图访问任何与/robots.txt或sitemapHT的URL,它把我送到domain.com /
With the current rules (below) When I try to access to any of the /robots.txt or sitemapHT urls, it sends me to domain.com/
该规则还从旧 /portal/index.action
URL重定向,我们有,到一个新的刚 /
The rules also are redirecting from old /portal/index.action
url we have, to a new just /
你能帮我解决规则正确地访问到previous网址吗?
Could you help me to fix the rules to access properly to the previous urls?
<VirtualHost *:80>
ServerAdmin administracion.linux@yellargentina.com
DocumentRoot "/opt/tomcat-5.5.30/webapps/portal"
ServerName hoteles.t1.yellargentina.com
ServerAlias hoteles.t1.yellargentina.com
CustomLog /tmp/hoteles-access_log combined
ErrorLog /tmp/hoteles-error_log
RewriteLog /tmp/hoteles-rewrite_log
RewriteLogLevel 3
JkUnMount /images/*.gif w1
JkUnMount /images/*.png w1
JkUnMount /images/*.jpg w1
JkUnMount /js/*.js w1
JkUnMount /styles/*.css w1
JkMount /portal w1
JkMount /portal/* w1
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
Options +FollowSymlinks
##
# Originales
##
##
RewriteRule ^/robots.txt /sitemapHT/robots.txt [R=301]
RewriteCond $1 !^/(sitemapHT/|portal/)
##
#RewriteRule ^/$ /portal/ [R]
#RewriteRule ^/(?!portal)(.*) /portal/ficha.action/$1 [PT]
RewriteRule ^/$ /portal/index.action [PT]
RewriteRule ^/portal/index.action / [R]
RewriteRule ^/(?!portal)(.*) /portal/ficha.action/$1 [PT]
</VirtualHost>
感谢您!
推荐答案
这两条线共同构成没有多大意义:
These 2 lines together make no much sense:
RewriteCond $1 !^/(sitemapHT/|portal/)
RewriteRule ^/robots.txt /sitemapHT/robots.txt [R=301]
这一行会做改写(如果你想重定向添加 R = 301,
旁边的→
) domain.com/robots.txt
到 domain.com/sitemapHT/robots.txt
:
This single line will do the job of rewriting (if you want redirect add R=301,
next to L
) domain.com/robots.txt
into domain.com/sitemapHT/robots.txt
:
RewriteRule ^robots\.txt$ /sitemapHT/robots.txt [L]
P.S。您改写日志(问题体内的最后code座)不可读。请正确格式化。
P.S. You rewrite log (the last code block in question body) is unreadable. Please format it properly.
P.P.S。如果你在你的.htaccess其他规则,它们可能会影响该重写规则。如果你提供整个的.htaccess如果这也不起作用这是更好。
P.P.S. If you have other rules in your .htaccess, they may affect this rewrite rule. It is better if you provide whole .htaccess if this one will not work.
更新:
1。不需要这一行:!的RewriteCond $ 1 ^ /(sitemapHT / |门户/)
,尤其是如果它的之后的重写规则
1. No need for this line: RewriteCond $1 !^/(sitemapHT/|portal/)
, especially if it after rewrite rule.
2。什么这2行吗?
2. What these 2 lines do?
RewriteRule ^/$ /portal/index.action [PT]
RewriteRule ^/portal/index.action / [R]
至于我 - 他们这样做相反的工作。但是,如果它的工作原理那么我不会去碰它。
As for me -- they do opposite jobs. But if it works then I will not touch it.
请尝试以下重写规则:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F,L]
RewriteRule ^/robots.txt /sitemapHT/robots.txt [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/portal/index.action\sHTTP/.+
RewriteRule ^/portal/index.action$ / [R,L]
RewriteRule ^/$ /portal/index.action [PT,L]
RewriteRule ^/(?!portal|sitemapHT)(.*) /portal/ficha.action/$1 [PT,L]
这篇关于阿帕奇:问题重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!