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
一直访问不了,请问哪里错了?

阅读 4.3k
3 个回答

你可以直接将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>

DocumentRoot 直接指向到topic不行? 相当于新建一个vhost

是想访问topic.luger.me映射到localhost:8080/topic吗?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进