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条)

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题