duanniling0018 2014-09-09 13:29
浏览 61
已采纳

htaccess mod_rewrite重定向到目录而不显示在url上

I have a site called www.example.com and I have my php files in it. I store all my working files in www.example.com/site. I want to view the site in www.example.com instead, without moving my site content. What can I do?

This is currently what I am typing in .htaccess. It will redirect my site to www.example.com/site but I think the url is ugly

RewriteEngine on
RewriteBase /

RewriteRule ^(/.*|)$ /magento$1 [NC,L]
  • 写回答

2条回答 默认 最新

  • dqeq885710 2014-09-09 14:00
    关注

    Let me see if i understood this correctly.

    You have a domanin, www.example.com, and on this domain you want to display the content of a directory, www.example.com/site !?

    If this is the case then you need to change the document root

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.example.com$
    RewriteCond %{REQUEST_URI} !^/site
    RewriteRule ^(.*)$ /site/$1 [L]
    

    or

    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^(.*)$ /site/$1 [L,NC]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?