首頁  >  問答  >  主體

apache RewriteRule 怎麼寫

tomcat有個項目topic,預設存取的時候是 localhost:8080/topic,現在綁定網域名稱topic.luger.me。 apache的config檔這樣寫的

<VirtualHost 127.0.0.1> DirectoryIndex /topic/index.jsp ServerName topic.luger.me Options FollowSymLinks rewriteengine on </VirtualHost>
訪問的時候還是topic.luger.me/topic才能訪問。怎麼寫RewriteRule規則才能存取的時候是
topic.luger.me
我這麼寫一直不對 ^(.*) /topic/$1
一直訪問不了,請問哪裡錯了?

PHP中文网PHP中文网2713 天前520

全部回覆(3)我來回復

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:05:35

    你可以直接將DocumentRoot 指定到topic 路径下,DirectoryIndex /topic/index.jsp

    <VirtualHost *:8080>
         ServerName topic.luger.me
         DocumentRoot "/var/www/topic"
         SetEnv APPLICATION_ENV "development"
         <Directory "/var/www/topic">
             DirectoryIndex index.jsp
             AllowOverride All
             Order deny,allow
             Allow from all
         </Directory>
    </VirtualHost>
    

    回覆
    0
  • 为情所困

    为情所困2017-05-16 17:05:35

    DocumentRoot 直接指向topic不行? 相當於新建一個vhost

    回覆
    0
  • 習慣沉默

    習慣沉默2017-05-16 17:05:35

    是想訪問topic.luger.me映射到localhost:8080/topic嗎?

    回覆
    0
  • 取消回覆