开发者

htaccess file somehow being cached?

I had a .htaccess file doing a very simple rewrite of the page names. This is the contents of the file:

Options +FollowSymlinks
RewriteEngine on
RewriteRule setup setup.php [NC]

I now want to stop rewriting setup to setup.php - how do I do this? I've tried removing the line from the file, I've tried deleting the file and restarting apache, and it is still rewriting setup to setup.php. How do I make it stop? It seems to be completely ignoring any other .htaccess file I create, and there's nothing being wr开发者_如何学Citten to the error log. Is it caching the file somewhere? How do I stop it?

I'm using apache2 on ubuntu.


If you are having problems with the htaccess file not updating due to the redirect getting cached in your browser. You can use a webkit browser like Google Chrome or Safari to open a private browsing session or Incognito Window.

Every time you update the htaccess file, you will need to close all incognito windows/tabs and then open a new one. The incognito window will not write to the cache beyond the current session and will not use the existing cache on initial load. It makes a great way to bypass caching issues when testing, and a great way to see if the issue you are having is caused by your browser's cache.

I am not sure, but Firefox and newer versions of IE might have a similar feature.


The problem is that MultiViews is enabled. MultiViews automatically adds extensions to any requested URLs, if possible. This has nothing to do with your RewriteRule; it just so happens that you were rewriting setup to setup.php so MultiViews and your rule were doing the same thing.

Add -MultiViews to the Options directive to disable it.


1) Check to make sure nginx is not causing problems for you - I just turned it off, but I'm sure there are ways to set it up properly if you want to use it. (For me it was set on by default on MediaTemple's newest DV servers).

2) Try adding this to httpd.conf or vhost.conf or some other configuration file further up the food chain from your home directory's htaccess file:

Header merge Cache-Control no-cache env=NO_CACHE
Header merge Cache-Control no-store env=NO_STORE


The solutions is, to open the file /etc/apache2/sites-available/default and change this:

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

Into this:

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

Note the AllowOverride directive - this file apparently overrides all other instructions elsewhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜