Forum Moderators: phranque

Message Too Old, No Replies

Modrewrite works but error in Server Log

htaccess and rewrite works but show error in server log?

         

howzit

5:37 pm on Mar 2, 2010 (gmt 0)

10+ Year Member



I am rewriting url's in my htaccess and it is working fine

The pages work as it should on the site but when I inspect my server error log it gives me the following error why?

[Tue Mar 02 18:18:30 2010] [error] [client 165.145.140.230] File does not exist: /home/server/public_html/thecat, referer: http://www.example.com/cat/subcat


In my htaccess:
RewriteRule ^([A-Za-z-]+)/([A-Za-z+-]+)$ /file.php?cat=$1&subcat=$2 [L]


The top of my htaccess:
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
##Header append X-FRAME-OPTIONS "DENY"
## Error document review
ErrorDocument 404 /index.php
AddType application/x-httpd-php .htm .xml .rss

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
RewriteRule ^(.*)$ – [F,L]
# remove trailing slash
RewriteRule (.*)/$ /$1 [L,R=301]

RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]

[edited by: jdMorgan at 6:59 pm (utc) on Mar 3, 2010]
[edit reason] Please use example.,com only. [/edit]

jdMorgan

7:25 pm on Mar 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps some problem related to the fact that you did not specify a protocol or domain in your redirect. Or perhaps mod_negotiation (MutliViews option) or AcceptPathInfo is interfering.

I'd suggest the following tweaks to what you have:

# Set options overriding server config (See Options and
# AllowOverride directives, and adjust as necessary)
Options -Indexes -MultiViews +FollowSymLinks
#
# Disable PathInfo if not used (Apache 2.0 and above only)
AcceptPathInfo Off
#
# Don't list these filetypes in directory index displays
# (if indexes are allowed -- see Options line above)
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
#
# Send X-Frame-Options HTTP response header (Corrected directive and case)
#Header set X-Frame-Options: "sameorigin"
#
# Define the custom 404 error document
ErrorDocument 404 /index.php
#
# Use php MIME-type kludge to invoke PHP interpreter
AddType application/x-httpd-php .htm .xml .rss
#
# Enable the rewrite engine
RewriteEngine On
#
# Forbid access by libwww or any request containing "=http" in the query string
RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
RewriteCond %{QUERY_STRING} \=http [NC]
RewriteRule ^.*$ – [F]
#
# Remove trailing slash on URLs rewritten below unless
# the requested URL-path resolves to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z-]+)/([a-z+-]+)/$ http://www.example.com/$1 [NC,R=301,L]
#
# Rewrite requested URL-paths of the form /dir/string to "file.php" script
RewriteRule ^([a-z-]+)/([a-z+-]+)$ /file.php?cat=$1&subcat=$2 [NC,L]
#
# Rewrite .xml requests to corresponding php files
RewriteRule ^(.*)\.xml$ /$1.php [NC,L]

This should be correct as well as faster in most cases, but I've made some assumptions about your URLs and the purpose of each rule (as commented).

Jim