php - .htaccess RewriteRule index -
first of apologize english.
i'm trying make pretty urls. unfortunately have little experience in area. .htaccess file contents like:
rewriteengine on rewriterule index/(.*)/(.*)/ index.php?category=$1&page=$2 rewriterule index/(.*)/(.*) index.php?category=$1&page=$2 rewriterule index/(.*)/ index.php?category=$1 rewriterule index/(.*) index.php?category=$1 rewriterule index/ index.php rewriterule index index.php
it works. rewriting link like:
site.com/index/department/workers
to:
site.com/index.php?category=department&page=workers
so index.php can work link. if there no "page" parameter third or fourth rule handles link. , on.
the problem in address bar there "index". link
site.com/department/workers
(without index)
is possible? or can give me advice how can rewrite rules?
you can remove index rewrite rules. ensure account requests match real files e.g.:
directoryindex index.php rewriteengine on rewritecond %{request_filename} !-f rewriterule ^(.+)/(.+)/?$ index.php?category=$1&page=$2 rewritecond %{request_filename} !-f rewriterule ^(.+)/?$ index.php?category=$1
this will:
- defined index.php index file
- rewrite requests of form
/something/somethingelse/
index.php?category=something&page=somethingelse
- rewrite requests of form
/something/
index.php?category=something
note don't need 2 rules account ends-with-/ , doesnt-end-with-/ - can account in single rule. more information on setting rewrite rules can found in the documentation.
Comments
Post a Comment