[solved] Matching in .htaccess file

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

semlar
Forum Commoner
Posts: 61
Joined: Fri Feb 20, 2009 10:45 pm

Re: Matching in .htaccess file

Post by semlar »

pickle wrote:Yes I am using a custom 404 page. That page is just a simple dump that says "file not found". Even when I comment out that line, nothing changes.
Does templates/whatever redirect to templates.php without any of your rewrites?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Matching in .htaccess file

Post by josh »

semlar wrote:Maybe the server is doing it by itself.
Negative, its happening on ubuntu only. It's got to be a stray rewrite from httpd.conf or some plugin. This is not default apache behavior by a long shot!
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

Ubuntu has an empty httpd.conf file. I've greped the apache2.conf file and the sites-enabled/000-default file for "php" - nothing found.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Matching in .htaccess file

Post by josh »

Hmm, oddest freakin problems always get to me... The only last thing I'd check is that the .php isnt getting dumped into the access log, if it is then its something before apache. I didn't even know you could have empty httpd.conf files 8O
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

I built another virtual host to test this on, as I didn't want to interfere with the project, which is now being tested by users.

Going to the root of that virtual host & requesting /templates/blah/wank/ puts just that string in the access log - no templates.php entry.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
semlar
Forum Commoner
Posts: 61
Joined: Fri Feb 20, 2009 10:45 pm

Re: Matching in .htaccess file

Post by semlar »

josh wrote:
semlar wrote:Maybe the server is doing it by itself.
Negative, its happening on ubuntu only. It's got to be a stray rewrite from httpd.conf or some plugin. This is not default apache behavior by a long shot!
I meant like a module built into ubuntu's apache, I took it out because it wasn't really clear.

You can set it up so apache looks for similarly-named files if the one requested isn't found, I don't remember how though.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Matching in .htaccess file

Post by VladSun »

:twisted:

Turn off Multiviews:

Code: Select all

Options -Multiviews
I've read somewhere it's because the order of loading Apache modules in Debian can be wrong (because of these mod-available/mod-enabled bloody directories and file listings): e.g. mod_negotiation is loaded before mod_rewrite. And the processing follows the module load order.
So, another solution to this problem is to set a proper module load order.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

I did that in sites-available/default (which is soft linked from sites-enabled/), restarted apache & no change.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Matching in .htaccess file

Post by VladSun »

My default file is like this:

Code: Select all

/etc/apache2/sites-available# cat default
NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost
 
        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks -MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
... 
You may also try not to load mod_negotiation
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

Mine looks pretty much the same:

Code: Select all

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    
    DocumentRoot /var/www/
    <Directory />
        Options FollowSymLinks -MultiViews
        AllowOverride All
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks -MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

I've come to the realization that if it requires all this server configuration to make the .htaccess redirection work, then I don't want to rely on the .htaccess . The goal is to make this as drop-in functional as possible. If the user has to configure their virtual hosts, that's not drop-in.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Matching in .htaccess file

Post by VladSun »

I think you can use Options -MuliViews in .htaccess files and per Directory basis.
Syntax: Options [+|-]option [[+|-]option] ...
Context: server config, virtual host, directory, .htaccess
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

Hot diggity! That did it. Putting "Options -MultiViews" in the .htaccess file fixed the problem.

Of course, doing a search for "apache multiviews" brings up a slew of people with my exact same problem. Thanks ~Vlad (and everyone else)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
semlar
Forum Commoner
Posts: 61
Joined: Fri Feb 20, 2009 10:45 pm

Re: Matching in .htaccess file

Post by semlar »

That is surprisingly hard to find when you don't know what it's called.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Matching in .htaccess file

Post by VladSun »

Just another reason I'd prefer Slackware over "user-friendly-package-super-powered" distributions :)
But...
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Matching in .htaccess file

Post by pickle »

This project was actually developed on SuSE 10 - we're a *sigh* Novell shop.

Deploying it on Ubuntu was just to work out any cross-distro bugs that may occur.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply