首页  >  问答  >  正文

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 天前518

全部回复(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
  • 取消回复