My rules are as follows:
- Code: Select all
RewriteEngine On
#It supposes to rewrite all requests with no path specified to index.php, "[QSA]" says to append the query string.
RewriteRule ^/$ /index.php [QSA]
#rewrite a path ending in "<something>.html" to
"index.php?id=<something>"The "[L]" means that if a url matches this rule, do not apply any of thefollowing rules to it.
RewriteRule ^/([A-Za-z0-9_-]+)\.html$ /index.php?id=$1 [L]
#If the current request does not have a cookie called "COOKIE_ADMIN_MODE" with a value of "true"
RewriteCond %{HTTP_COOKIE} !(COOKIE_ADMIN_MODE=true)
#If the current request has a query string starting with "id=" or "cID="
and the part following that is not a number and not empty.
RewriteCond %{QUERY_STRING} ^(id|cID)=[^0-9][^&]+$
#Take the match from the condition above and match the part of it between the "=" and the end.
RewriteCond %0 [^=]+$
#Finally, Rewrite any path (but this rule is only applied if the above conditions
are true) to the match from the rule above with ".html" appended.
The "?" clears the query string. The "R=301" means make this an external redirect (send a redirect header to the browser so that it changes the url pointed to) and indicate that
the content has permanently moved.
RewriteRule .* %0.html? [R=301,L]
That's the code I have in my .htaccess file, it is located on my /public_html folder where the content of my site. The problem is that when I click in some of the menu options the 404 not found appears.
The redirect is pointed to something like:
http://www.example.com/home/example/pub ... wpage.html
instead of:
http://www.example.com/newpage.html
It gets the full path of the site, I don't know why, hence don't know how to fix it 'cause I'm new in mod_rewrite.
Thanks in advance!
Víctor