简体   繁体   中英

.htaccess in subdirectory

I've been searching the whole evening for a solution/approach for my problem with my .htaccess file.

Basically I have www.site.com with a .htaccess in the www directory with the following content:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(/admin)
RewriteRule ^[^_+/]. index.php

It works just fine and allows www.site.com/en/articles/Interesting_title/3 to be parsed by index.php which reads which controller, language and what article to display.

However I'd like for the admin system to work the same way. www.site.com/admin should have an .htaccess files that allow me to write URL's this way.

www.site.com/admin/en/articles/article_title/3 should allow me to edit article number 3 using en english UI.

Dumping $_SERVER['REQUEST_URI'] in the first case gives "en/articles/Interesting_title/3"
Dumping $_SERVER['REQUEST_URI'] in the second case gives "admin/en/articles/article_title/3"

If I at a later point choose to move administration to www.site.com/shassooo I would like to avoid changing any code other then the .htaccess files.

Cheers

Append this line in the same .htaccess file you have, not under admin sub directory:

RewriteCond %{REQUEST_URI} !^/admin/index.php$ [NC]
RewriteRule ^admin/[^_+/]. /admin/index.php [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM