My current .htaccess file is pasted below. I noticed recently that a function I had placed only on the homepage of my website (root URL) was running every time I loaded any page of my website. I searched all relevant classes and files to see if anything in my PHP code was doing this, then found it was definitely related to mod_rewrite.
Once I set “RewriteEngine off” the home page (root URL) was not being run any more when viewing other pages. How can I prevent it from seemingly sending two requests instead of one? URLs on my website are structured like so: mysite.com/page-name
RewriteEngine on
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# File access
# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>
<Files ~ "\\install.xml$">
Order allow,deny
Deny from all
Satisfy All
</Files>
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)?$ index.php?url=$1 [L]
I’m sorry you feel that way but, IMHO, that says more about you than me.
Think how many people I’ve helped here who have at least attempted to learn what they were doing rather than ask for something they can’t even define. That’s a LOT of hours helping that many people so I don’t have a problem asking a member to learn what they’re doing with mod_rewrite (something any webmaster would do without being asked).
That makes sense. I don’t suppose you could provide me with the necessary additions / edits? I don’t understand the proper syntax or commands to use in these files. I prefer to stick to PHP/MySQL.
[rant #3][indent]My purpose for being here is to share knowledge, not to do free coding. I consider requests for free code to be from “script kiddies” and will not respond to them. Take the time and make an effort to learn and you’ll get all the assistance you need![/indent][/rant #3]
Okay, now that’s out of my system, I’ll point you to the tutorial article linked in my signature. THEN, because I have to GUESS at that you REALLY want done, say that “the exclusion” that you need to add to your .htaccess BEFORE the CMS code is to redirect TO a servable URI (which would make the CMS code ignore because of the -f RewriteCond statement). Don’t worry, the tutorial has a code snippet for dealing with extensionless URIs AND I’ll be glad to help you make sure that YOUR code is letter perfect.
Your mod_rewrite is set to redirect everything which does NOT resolve to an existing directory or file to index.php. If you’re using links like mysite.com/page-name, unless page-name is a file or directory, it is SUPPOSED to be redirected to index.php. In other words, you need some special handling of extensionless URIs BEFORE getting to your CMS’s mod_rewrite.