I got an .htaccess file must to rewrite URLs for SEO friendly website,
So when i click on eg. an article ( eg www.example.com/article/this-is-an-artcle/ ) must to redirect me to index.php?article=this-is-an-article.
Same thing I must to do with the category page and admin page, so for completeness is something like this
www.ex.com/index.php?article=example-article -> www.ex.com/article/example-article
www.ex.com/index.php?category=example -> www.ex.com/category/example
www.ex.com/index.php?page=admin -> www.ex.com/adm
Instead of this I must to hide the index.php file from the URL.
I’m doing this, but produce a 404 error
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} . [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^article/([w-]+)/?$ index.php?article=$1 [QSA,L,NC]
RewriteRule ^category/([w-]+)/?$ index.php?category=$1 [QSA,L,NC]
RewriteRule ^adm/?$ index.php?page=admin [QSA,L,NC]
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Unfortunately If I open the apache.err.log can’t see errors relating to the RewriteEngine, so i’ve tried to use LogLevel alert rewrite:trace6
in my .htaccess file, but didn’t produce log, also tried to put a rewrite.log file in site folder, and make 777 permissions, no change, file still blank.
EDIT: Since this file work in another server ( cloud9 IDE ) and here not ( AWS Ubuntu 14.04 ) I’m assuming that I miss some configuration. How I can enable the LOG to see what’s happen?
3
Answers
Run it through a syntax checker perhaps
E.g. http://www.htaccesscheck.com/
You are probably getting 404 error status becouse of the relative rewrite targets, add a slash before your traget paths ie 🙁 /index.php )
andreaem, try this: