Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

.htaccess URL Rewrite to Subdirectory

What is the best method to rewrite anything below "/some/subdir" to "/some/subdir/projects" like from this:

http://www.mydomain.com/some/subidr/test/

... to this:

http://www.mydomain.com/some/subdir/projects/test/

I found a similar question posted, but the solution didn't seem to work in my case. My current attempt so far (which doesn't seem to work):

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/projects/.*$
RewriteRule ^(.*)$ /projects/$1 [L]

EDIT: I forgot to mention the .htaccess file would have to be sitting within /some/subdir as I don't have write access to the server's web root.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is the solution I finally got to work:

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/some/subdir/projects/.*$
RewriteRule ^(.*)$ /some/subdir/projects/$1 [L]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...