htaccess映射/ path到path之后的任何内容

时间:2013-06-26 21:45:11

标签: apache .htaccess mod-rewrite url-rewriting rewrite

以下是该方案:

我有一个网站,它使用各种mod_rewrites来删除文件扩展名等。我现在需要的是将任何流量发送到/ path / something / something / to / path /但保持分段。

这是我的文件,它是导致问题的最后一条规则,它重定向到/ path而不是保留路径名和渲染/路径

RewriteEngine On

RewriteCond %{THE_REQUEST} ^GET\s(.*/)index\.php [NC]
RewriteRule . %1 [NE,R=301,L]

RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC]
RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

#This is the problem child!
RewriteRule ^path/([^/]+)/(.*)$ /path [NC]

提前感谢任何提示!

1 个答案:

答案 0 :(得分:0)

看起来我通过反复试验偶然发现了解决方案:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^path/(.*)$ path/index.php/$1 [L]

也许应该在问题中提到index.php!

相关问题