.htaccess在使用网址路由

时间:2015-11-11 19:32:00

标签: apache .htaccess mod-rewrite redirect

我有这个.htaccess文件

RewriteEngine on
RewriteBase /

RewriteRule ^pdf/([^/]+)/?$ pdf.php?file=$1&post=1 [QSA]
RewriteRule ^pdf/([^/]+)/([^/]+)/?$ pdf.php?file=$1&id=$2 [QSA]  

RewriteRule ^file/([^/]+)?$ file.php?file=$1 [QSA]  
RewriteRule ^file/([^/]+)/([^/]+)?$ file.php?file=$1&find=$2 [QSA]  
RewriteRule ^file/([^/]+)/([^/]+)/([^/]+)?$ file.php?file=$1&type=$2&find=$3 [QSA]  

RewriteRule ^([^/]+)/graphs/([^/]+)/?$ index.php?route=$1/graphs&view=$2 [QSA]  

RewriteRule ^(.*)\.html$ $1.php [NC]
RewriteRule ^(.*)\.html$ $1\.php [T=application/x-httpd-php,L]

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

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

这适用于 sub.domain.com

但是当我将整个内容复制到 new.sub.domain.com 时,现在正在重定向被称为图像的实际文件,

因此,如果调用images/image.png,则会将其发送到index.php?route=images/image.png而不是预期的图像。它确实在请求的位置退出。

任何人都可以解释为什么或在某处我做错了。

我认为这一点整理了重定向的真实文件

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

或在sub.sub.domains

时更改

网站的位置

[works] /subdomains/sub/htdocs/
[doesn't work] /subdomains/sub.sub/htdocs/

apache从服务器根目录运行/subdomains/文件夹中的所有子域。

0 个答案:

没有答案