.htaccess URL 重写到子目录 [英] .htaccess URL Rewrite to Subdirectory
本文介绍了.htaccess URL 重写到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将/some/subdir"下面的任何内容重写为/some/subdir/projects"的最佳方法是什么:
What is the best method to rewrite anything below "/some/subdir" to "/some/subdir/projects" like from this:
http://www.mydomain.com/some/subidr/test/
...到这个:
http://www.mydomain.com/some/subdir/projects/test/
我发现发布了一个类似的问题,但解决方案没有似乎在我的情况下工作.到目前为止,我目前的尝试(似乎不起作用):
I found a similar question posted, but the solution didn't seem to work in my case. My current attempt so far (which doesn't seem to work):
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/projects/.*$
RewriteRule ^(.*)$ /projects/$1 [L]
我忘了提到 .htaccess 文件必须位于/some/subdir 中,因为我没有对服务器 Web 根目录的写访问权限.
I forgot to mention the .htaccess file would have to be sitting within /some/subdir as I don't have write access to the server's web root.
推荐答案
这是我终于开始工作的解决方案:
This is the solution I finally got to work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/some/subdir/projects/.*$
RewriteRule ^(.*)$ /some/subdir/projects/$1 [L]
这篇关于.htaccess URL 重写到子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文