Home  >  Q&A  >  body text

About Apache’s .htaccess issue

Hello everyone! My current requirement is: When the entered URL address is http://www.lazyer.com/lazyer/frontend/web/site/login, force the redirection to http://www.lazyer.com/site/login . For this purpose, I wrote a .htaccess file in the server root directory. The code inside is as follows:

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteBase / 

    RewriteCond %{HTTP_HOST} ^www\.lazyer\.com$
    RewriteCond %{REQUEST_URI} ^/lazyer/frontend/web/
    RewriteRule ^lazyer/frontend/web/(.*)$ http://www.lazyer.com/ [L,R=301]

</IfModule>

apache has also enabled the rewrite function, but when entering http://www.lazyer.com/lazyer/frontend/web/site/login, there is no redirection effect. What's going on?

阿神阿神2713 days ago547

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 17:02:24

    The first letter of Lazyer in your URL is capitalized, right? The rule is to write less.

    It is recommended that you first write an absolutely matching rule to verify whether the configuration is valid. Such as:
    RewriteRule .* http:://segmentfault.com [R,NC]

    reply
    0
  • Cancelreply