| .htaccess Custom ErrorDocument problem after multiple conditions .htaccess ErrorDocument do not work after multiple conditions |
jabz

msg:4208971 | 7:29 pm on Sep 29, 2010 (gmt 0) | Hi, I have a problem with my custom errorpage (ErrorDocument). First, please have a look at my current .htaccess file: # needs to stay inline Options +Indexes +FollowSymlinks -MultiViews Options -Indexes RewriteEngine on DirectoryIndex index.php # REDIRECT Force requests for named index files to drop the index file filename, and force www to avoid redirect chains: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php[45]?)(\?[^\ ]*)?\ HTTP/ RewriteRule ^(([^/]*/)*)index\.(html?|php[45]?)$ http://www.domain.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/([^\.]+)\.php\ HTTP/ RewriteRule ^(en|de|ar)/([^.]+)\.php$ http://www.domain.com/$1/$2 [R=301,L] # REDIRECT all non-canonical hostname requests to canonical hostname RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.domain\.com$ RewriteRule (.*) http://www.domain.com/$1 [R=301,L] # REWRITE url to filepath RewriteRule ^(en|de|ar)/([^/.]+)$ /$1/$2.php [L] # custom errorpages ErrorDocument 404 /404.html |
| Short Summary I have three language folders and (en, de, ar) and multiple files (PHP) in each folder. My .htaccess helps me to work with extensionless URLs. My Problem: I just tried to add a custom errordocument to that .htaccess file. Unfortunately it only works for URL typos within root, but not within my three language folders. I've tried several things to fix this...but here I am. Can somebody help me out? Thanks in advance. [edited by: tedster at 4:36 pm (utc) on Sep 30, 2010] [edit reason] member requested fix [/edit]
|
jdMorgan

msg:4209342 | 2:21 pm on Sep 30, 2010 (gmt 0) | You've declared a server-relative path to your 404 ErrorDocument instead of a directory-relative path, which means that all 404 errors will serve domain.com/404.html regardless of the requested subdirectory. Is that NOT what you want? What is the specific problem - What result did you want? Your second rewriterule should be unnecessary, as the first one should already handle all subdirectories, including the language subdirectories. I'd suggest that you comment-out that second rule and test. If language subdirectories can still be requested with .php-extension URLs and don't get redirected to remove the ".php", then something is wrong with your first rule or with the "RewriteOptions inherit" setting. You can eliminate the first rewritecond from your third rule by modifying its second rewritecond to
RewriteCond %{HTTP_HOST} !^(www\.domain\.com)?$ This is simply a shorter/faster equivalent method. Jim [edited by: tedster at 4:37 pm (utc) on Sep 30, 2010] [edit reason] member requested fix [/edit]
|
|
|