Jump to content

mod_rewrite Rule that normally works....not working.


aspacecodyssey

Recommended Posts

Hi, I'm doing a simple hiding of ".php" from everything (i.e. www.website.com/subpage will mask to www.website.com/subpage.php).

 

I'm using the following Rewrite rules:

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

 

This has worked for me many many times before. Currently, it's set up at this website:

http://www.danbarryfilms.com/

 

But, as you can see by trying http://www.danbarryfilms.com/resume (which should show http://www.danbarryfilms.com/resume.php), it's not working. However, for some odd reason, if you try http://www.danbarryfilms.com/welcome it will redirect to http://www.danbarryfilms.com/welcome.html -- even though there is no rewrite rule concerning .html files, AND even if there is no .htaccess file present on the server.

 

This is a GoDaddy server...I'm not sure if that means anything.

Link to comment
Share on other sites

Sorry, I'm not familiar with that -- is there any solution on my end, or would this be all GoDaddy? I've been back and forth with their support team, but they keep insisting it's coding related (though I think they may be doing that because they don't provide coding support, and I've shown them about 15 other sites I've made that use exactly the same rewrite code and work properly).

Link to comment
Share on other sites

What seems to be happening is MultiViews is in the virtual hosts <directory> definition. This will attempt to find the file as .html first so it automatically redirects it to .html. This does cause issues have you have just noticed, with re-writing of some URLs.

 

I am not 100% positive that is what is happening, but you can try and turn off the MultiViews in the .htaccess (I never tried it before) or add it to search for .php first and then you would not need the custom rewrite rules. I am not 100% sure on how to do this, but viewing the link Cags posted should lead you to some good information. Googling "MultiViews htaccess" may also yield some good results.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.