【发布时间】:2014-02-11 19:38:02
【问题描述】:
编辑:你可以在这里看到我的意思:Test Page
页面上的图像是不相关的。它们一直工作到移动到 /test/n/ 或更深。 页面源显示正确链接的图像(非相对,正确的路径),但查看它们、复制它们的 url 并使用内联编辑器检查它们会将 url 显示为相对并破坏它。
例如,假设我使用路径 http://url.com/images/image.jpg - 如果我从 http://www.url.com/n/x/y/ 查看它 查看源代码时路径保持不变,但在其他地方显示为 /images/image.jpg 或 http://www.url.com/n/x/y/images.jpg
我发现它更令人困惑,因为链接的样式表和超链接仍然可以按预期工作。
我的测试文件夹中有以下 .htaccess 文件
RewriteEngine on
RewriteBase /test/
#
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
#
# Rewrite /test/n/x/y-p/
RewriteRule ^([^/]+)/([^/]+)/([^/]+)-([0-9]+)/$ index.php?n=$1&x=$2&y=$3&p=$4 [L,NC,QSA]
#
# Rewrite /test/n/x/y/
RewriteRule ^([^/]+)/([^/]+)/([^/]*)/$ index.php?n=$1&x=$2&y=$3 [L,NC,QSA]
#
# Rewrite /test/n/x-p/
RewriteRule ^([^/]+)/([^/]+)-([0-9]+)/$ index.php?n=$1&x=$2&p=$3 [L,NC,QSA]
#
# Rewrite /test/n/x/
RewriteRule ^([^/]+)/([^/]*)/$ index.php?n=$1&x=$2 [L,NC,QSA]
#
# Rewrite /test/n-p/
RewriteRule ^([^/]+)-([0-9]+)/$ index.php?n=$1&p=$2 [L,NC,QSA]
#
# Rewrite /test/n/
RewriteRule ^([-_a-zA-Z-]*)/?$ index.php?n=$1 [L,NC,QSA]
【问题讨论】:
标签: html image apache .htaccess mod-rewrite