Forum Moderators: phranque
it gave me the following error;
The requested URL /country/2/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
And the requests is rewritten as follows:
domain.com/country/2/ -> domain.com/Category.php?page=2
public_html/.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^/country/([0-9]+)/$ Category.php?page=$1[L]
and all the file i use here, they sit in the directory of the public_html.
when i click on the following link, it tell me the above error;
<a href="/country/2/"> click me </a>
RewriteRule ^country/([0-9]+)/$ /somepath/Category.php?page=$1 [L]
.
As for the "!-f" and "!-d" stuff, my guess is that it means that there is no rewrite called if there is a real file located at the "friendly URL" location.
So if /somepath/somefile.html exists, then that is what is directly served without any sort of rewrite.
.
Finally, do make sure that you have sorted out any non-www to www canonicalisation issues, earlier in the .htaccess file, BEFORE calling this rewrite.
Jim
Finally, do make sure that you have sorted out any non-www to www canonicalisation issues, earlier in the .htaccess file, BEFORE calling this rewrite.
For the above you mentioned, i have some information about the AuthName, AuthUserFile & AuthGroupFile in my .htaccess already, is that what you want me to do?
Once you have got the rule working, you also need to create the custom 404 error document that you (or your host) have defined using the "ErrorDocument 404" directive. This file is apparently missing, which is the cause of the "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request" message.
For the above you mentioned, i have put the following line in my .htaccess file:
ErrorDocument 404 /404.html
and also the file of the 404.html is sitted on the /public_html/, i also wrote some thing into file. Is that you want me to do?
The non-www to www redirect is this one:RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]and makes sure that only www URLs are indexed for the entire site.
Thanks G1smd:
I 'd like to ask you some question:
1) without of your rewrite rule, the mod_rewrite create the dynamic url properly.
Do you just want to make 100% safty to creating dynamic url, so you advice me to add the
rewrite rule for the non-www to www redirect on?
2) what the "R=301" means?
3) If i want to create a rewrite rule which has two group parts from a rewrite rule,
for example, RewriteRule ^([^/]+)/([^/]+)/?$ foo.php?name1=$1&name2=$2.
Do i need to add another rewrite rule as the following:
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^([^/]+)/([^/]+)/?$ [domain.com...] [R=301,L]
If a user requests a non-www URL from your site, the redirect forces the browser to make a new request for the www version of the page.
Once that has been done, your original rewrite can kick in and fetch the content from the dynamic filepath.
So, the code is an additional instruction that goes before your rewrite.
The [R=301] forces the server to issue an external 301 redirect, instead of performing an internal rewrite.
Your original rewrite will deliver content whether you request the www or the non-www URL. That is a Dupllicate Content problem. The preceding, new, redirect fixes the site so that non-www will redirect to www, and www will deliver the content via your rewrite.
The code I gave is a redirect, not a rewrite.If a user requests a non-www URL from your site, the redirect forces the browser to make a new request for the www version of the page.
Once that has been done, your original rewrite can kick in and fetch the content from the dynamic filepath.
So, the code is an additional instruction that goes before your rewrite.
The [R=301] forces the server to issue an external 301 redirect, instead of performing an internal rewrite.
Your original rewrite will deliver content whether you request the www or the non-www URL. That is a Dupllicate Content problem. The preceding, new, redirect fixes the site so that non-www will redirect to www, and www will deliver the content via your rewrite.
Thanks for your helping.an i very appreciate about that