简体   繁体   中英

apache2 rewrite rules not working

I am trying to write some rewrite rules in apache2 conf and they are not working Following is my virtualhost block in apache conf. My os is ubuntu 12.04 server edition

    DocumentRoot /var/www/xyz

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/xyz>
            Options Indexes FollowSymLinks MultiViews
            #AllowOverride None
            AllowOverride All
            Order allow,deny
            #Order deny,allow
            allow from all
     </Directory>

I have .htaccess file with some rewrite rules as follows

ReWriteEngine on
RewriteRule    ^/matchV/(.*) http://host:8080/$1
RewriteRule    ^/other/(.*?)$ /httpdcontent/$1

rewrite module is enabled with apache.

Can someone tell me if i am missing anything.

Thanks,

Sandeep

First of all, a dollar sign seems to be missing on the first rewriting rule. Then, I would recommend the use of [L] in "debug" situation. This way, only one rule would have to be corrected at the time.

If you need to check how the rewriting goes, you need to have a look at your log files /var/log/apache2/error.log and /var/log/apache2/access.log. They will tell you what URL the server tried to process, and how it failed. From this, you should be able to see what is missing, or what is "too much".

From what I see, I would say it has to do with the rewriting base. Your webserver root is probably at /var/www, and the directory for the virtual host is /var/www/xyz. I think you could fix it using something like...

RewriteBase /xyz

Anyway, edit the configurations, and don't stop checking the logs. From there, you'll see what URL/File the server tries to process, and you should be able to correct the paths it uses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM