我正在寻找.htaccess
文档/教程,但没有正确使用它,我不知道现在学习或其他什么不是我的水平。
还请推荐学习.htaccess的链接
但在这里我必须设置我的网址
在服务器上我的主网站在根目录
上
除此之外,我将其他网站放在子目录/sites
中作为
/sites/myblog
/sites/myfriends
/sites/other
目前正在访问这些www.domain.com/sites/myblog
但是我想将其网址设置为www.domain.com/myblog
替换sites
我正在使用apache
答案 0 :(得分:0)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
RewriteBase /
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# it is not already /sites/
#RewriteCond %{REQUEST_URI} !^/sites/ [NC]
RewriteRule ^ sites%{REQUEST_URI} [L]
还有一些关于mod_rewrite
的好文档: