php - Apache2 setting up mod_rewrite and restricting access without .htaccess file -


i following tutorial:

http://www.phpro.org/tutorials/model-view-controller-mvc.html

the tutorial states should use htaccess file. however, apache2 documentation advises enter .htaccess rules standard configuration files better performance.

i'm working in /etc/apache2/sites-available/default.

this have far:

<directory /var/www/>     options indexes followsymlinks multiviews     allowoverride     order deny,allow     deny </directory>  <directory /var/www/> rewriteengine on     rewritecond %{request_filename} !-f     rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?rt=$1 [l,qsa] </directory>  <location /index.php> order allow,deny allow </location> 

with these rules, index.php accessible, index.php?rt=blog still works, , index/blog or /blog not. doing wrong?

but index.php?rt=blog still works

you don't have rules make doesn't work

and index/blog or /blog not

you don't have rules make urls work, though "/blog" should rewriting /index.php?rt=/blog.

try like:

<directory /var/www/>     rewriteengine on      rewritecond %{the_request} \ /+index\.php?rt=([^&\ ]+)     rewriterule ^ /%1? [l,r]      rewriterule ^/index/(.*)$ /$1 [l,r]      rewritecond %{request_filename} !-f     rewritecond %{request_filename} !-d     rewriterule ^/(.*)$ /index.php?rt=$1 [l,qsa] </directory> 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -