3

I have set up a development server with Ubuntu and LAMP, but for some reason the .htaccess is acting strange...

There is a site on there with a set of rules, when I comment them out they still work, and even when I renamed the file to .htaccesss it still works! If I delete everything in the file it still works, restarting Apache every time I make a change...

I have tried reinstalling Apache and reinstalled the rewrite module, and it still doesn't work...

Any new rules I add seem to not have any affect at all, so it is reading the rules from somewhere else it seems.

If I cause a syntax error by putting a / in the .htaccess file I do get a 500 server error.

Is there a place with cached rules? I've never had this problem before!

EDIT: I solved this problem by adding Options -Multiviews in my .htaccess file

4
  • After renaming .htaccess did you reload or restart apache? Try this and see it helps /etc/init.d/apache2 reload
    – ZVIK
    Oct 8, 2013 at 9:32
  • Yes I even reinstalled it
    – Adam
    Oct 8, 2013 at 9:33
  • Ok I have looked in the log and it seems there is something called a pass through active? its basically removing the php extension but I have no idea where it is coming from...
    – Adam
    Oct 8, 2013 at 10:04
  • 1
    I have solved the issue by adding: Options -Multiviews
    – Adam
    Oct 8, 2013 at 10:49

5 Answers 5

3

It might be worth to check whether the caching happens on the client and not server-side. Firefox will cache any 301 (PERMANLTY moved)-redirecteds for a few days. Use 302 (temporary) redirect. To fix "old targets" you can set up an html page redirecting to another domain (e.g. without www) etc. to prevent firefox from using its cache.

1

Is there a place with cached rules? I've never had this problem before!

(usually) not server-side, but client / browser-side; try to cache-clean your browser as well


EDIT 1

suggestion: move out the .htaccess - file from your docroot. when there are still rewrite-rules active, they must be somwhere: either in your docroot or in <virtualserver> - config. to disable htaccess for your docroot, add the following to your server-config:

<virtualHost>
    ...
    DocumentRoot /some/path
    ...

    <Directory /some/path>

        AllowOverride None

    </Directory>

</VirtualHost>  
  • restart apache

If your are sure your dont have any RewriteRule in your Server-Config AND with teh snippet above still get rewrites, i smell fish

6
  • I've cleared it, tried different computers and accessed it by IP instead of a hosts file domain, still working
    – Adam
    Oct 8, 2013 at 9:32
  • strange. what happens when you move the file out of your docroot? Oct 8, 2013 at 9:36
  • and there is a special rewrite-log; i'd turn it on on loglevel 5-9 and see whats happening. after this, i'd cd $docroot && find ./ -name '.ht*' -ls ; maybe some file is accidentially placed somewhere else in your docroot Oct 8, 2013 at 9:38
  • I just noted when I ran usr/sbin/apache2 -V it says: "Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" isn't that supposed to say httpd.conf?
    – Adam
    Oct 8, 2013 at 9:46
  • Ok I have looked in the log and it seems there is something called a pass through active? its basically removing the php extension but I have no idea where it is coming from...
    – Adam
    Oct 8, 2013 at 10:06
1
  1. Open browser inspector. (CTRL + SHIFT + I).

  2. Switch to network tab

  3. Check the Disable Cache checkbox and refresh the site.

0

Add Options -Multiviews in the .htaccess file.

Answered by Adam but wasn't visible so here it is, it works!

0

This may not help everyone, but in my case I discovered I had an old copy of .htaccess sitting in a parent directory of my site, actually a couple of directories up from my apache htdocs folder and it seems apache traverses up the directory tree and must merge this and my .htaccess in my htdocs folder. Once I discovered this errant file and removed it the redirect that wouldn't die stopped redirecting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .