Forum Moderators: phranque
ErrorDocument 404 /common/errors/404.php
IndexIgnore *
Options All
Options +FollowSymLinks -Indexes
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Remove index file
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(php|html)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(php|html)$ /$1 [NC,R=301,L] [edited by: incrediBILL at 8:41 pm (utc) on Apr 12, 2012]
[edit reason] exemplified URLs [/edit]
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^(.*)$ ht tp://www.%1/$1 [R=301,L] RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(php|html)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(php|html)$ /$1 [NC,R=301,L] # -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.com
AuthUserFile /home/example/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/example/public_html/_vti_pvt/service.grp
ErrorDocument 404 /common/errors/404.php
Options All
Options +FollowSymLinks -Indexes
<Files *.php>
AcceptPathInfo Off
</Files>
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# Remove index file
RewriteCond %{THE_REQUEST} index\.(php|html) [NC]
RewriteRule ^(([^/.]+/)*)index\.(php|html)$ http://www.example.com/$1 [NC,R=301,L] Does your site actually use both .php and .html?
Does your site actually use parameters anywhere? If yes, are they part of visible page names, or only used behind the scenes as the result of a Rewrite?
A 200 response doesn't happen in a vacuum. Where are these bogus requests going? Remember that your logs don't show rewrites (as opposed to redirects). You can only deduce them from the filesize-- the number after the 200. If you've got a php script that handles all requests, the explanation may lie there rather than in htaccess.
If you've set
Options -Indexes
then what does the
IndexIgnore *
directive do? It seems superfluous.
As far as I can see a request for www.example.com/index.php/nonsense/rubbish/non-existant.php serves the content found at www.example.com/index.php
Now, a normal URL only contains one full stop: the one right before the extension. (Only yesterday there was a question elsewhere in this Forum about filenames with multiple full stops, like .txt.zip. Can we assume you don't have anything like that?)
ErrorDocument 404 /common/errors/404.php
Options All
Options +FollowSymLinks -Indexes
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} !^(www\.travel-adaptor\.com)?$
RewriteRule (.*) http://www.travel-adaptor.com/$1 [R=301,L]
# Remove garbage info after .php
RewriteRule ^([^.]+\.php)[/.] http://www.travel-adaptor.com/$1 [R=301,L]
# Remove index file
RewriteCond %{THE_REQUEST} index\.(php|html) [NC]
RewriteRule ^(([^/.]+/)*)index\.(php|html)$ http://www.travel-adaptor.com/$1 [NC,R=301,L]
# Remove trailing slash
RewriteRule ^(.+[^/])/$ http://www.travel-adaptor.com/$1 [R=301,L] I wasn't aware that browsers reacted differently to urls and I assume that what is shown in Firefox's address bar is the result of its own 'cosmetic' rewriting or something. As I am interested in how the search engines see my urls I need to remove the trailing slash as well for consistancy.
RewriteRule ^(.+[^/])/$ http://www.example.com/$1 ErrorDocument 404 /common/errors/404.php
Options All
Options +FollowSymLinks -Indexes
RewriteEngine On
# Remove garbage info after .php
RewriteRule ^([^.]+\.php)[/.] http://www.travel-adaptor.com/$1 [R=301,L]
# Remove index file
RewriteCond %{THE_REQUEST} index\.(php|html) [NC]
RewriteRule ^(([^/.]+/)*)index\.(php|html)$ http://www.travel-adaptor.com/$1 [NC,R=301,L]
# Remove trailing slash
#RewriteRule ^(([^/.]+/)*[^/.]+)/$ http://www.travel-adaptor.com/$1 [R=301,L]
# Force www
RewriteCond %{HTTP_HOST} !^(www\.travel-adaptor\.com)?$
RewriteRule (.*) http://www.travel-adaptor.com/$1 [R=301,L] Can anyone shed any light as to how I can convince my server to throw a 404 for requests like this:
mydomain.com/index.php/Russia.php?x=blue-widgets/Russia.php
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.com
AuthUserFile /home/example/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/example/public_html/_vti_pvt/service.grp
ErrorDocument 404 /common/errors/404.php
Options All
Options +FollowSymLinks -Indexes
RewriteEngine On
# Remove garbage info after .php
RewriteRule ^([^.]+\.php)[/.] http://www.example.com/$1 [R=301,L]
# Remove index file
RewriteCond %{THE_REQUEST} index\.(php|html) [NC]
RewriteRule ^(([^/.]+/)*)index\.(php|html)$ http://www.example.com/$1 [NC,R=301,L]
# Force www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] Ask the support why this directive in .htaccess gets ignored.
Check the Apache manual for the exact AcceptPathInfo syntax.
The treatment of requests with trailing pathname information is determined by the handler responsible for the request. The core handler for normal files defaults to rejecting PATH_INFO requests. Handlers that serve scripts, such as cgi-script and isapi-handler, generally accept PATH_INFO by default.