Home  >  Q&A  >  body text

How to write apache RewriteRule

Tomcat has a project topic, which is accessed by default at localhost:8080/topic and is now bound to the domain name topic.luger.me. The config file of apache is written like this

<VirtualHost 127.0.0.1> DirectoryIndex /topic/index.jsp ServerName topic.luger.me Options FollowSymLinks rewriteengine on </VirtualHost>
When accessing, you can still access topic.luger.me/topic. How to write RewriteRule rules so that they can be accessed when
topic.luger.me
I have always been wrong when writing this ^(.*) /topic/$1
I can't access it all the time. What's wrong?

PHP中文网PHP中文网2713 days ago522

reply all(3)I'll reply

  • 曾经蜡笔没有小新

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

    You can directly 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>
    

    reply
    0
  • 为情所困

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

    DocumentRoot can’t point directly to the topic? Equivalent to creating a new vhost

    reply
    0
  • 習慣沉默

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

    Do you want to access topic.luger.me and map it to localhost:8080/topic?

    reply
    0
  • Cancelreply