3

I have several pages in

http://localhost/template

like home.php, about.php, contact.php

In http://localhost/template/sr I have the pages with the same name.

This is what I have in my root .htaccess file

RewriteEngine on
RedirectMatch 301 ^/$ http://localhost/template/sr/

My error.log file reports:

[localhost/sid#923dd8][rid#dd70b0/initial] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/
[localhost/sid#923dd8][rid#ddd0c8/subreq] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/index.php
[localhost/sid#923dd8][rid#ddb0c0/initial] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/
[localhost/sid#923dd8][rid#ddd0c8/subreq] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/index.php

This setup doesn't redirect I keep getting the pages from the root directory.

4

1 回答 1

4

If you're trying to redirect pages to coresponding pages in subdirectory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^([^/]+)/?$ /template/sr/$1 [L]
于 2013-09-21T12:43:15.890 回答