[英]Don't rewrite particular subfolder
I'm using the following .htaccess
to rewrite all URLs to my index.php file if they're not actual files or folders: 我使用以下
.htaccess
将所有URL重写为index.php文件,如果它们不是实际的文件或文件夹:
Options +FollowSymLinks
RewriteEngine On
// This bit redirect www.mydomain.com to mydomain.com
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
// This bit redirects all requests to index.php if a file or directory
// bearing that name doesn't exist
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
I'm now adding an admin
section to my website and I would like to not rewrite this particular URL: 我现在要在我的网站上添加一个
admin
部分,并且我不想重写这个特定的URL:
mydomain.com/admin
I would like that case to be treated as it would be by default (in this case defaulting to mydomain.com/admin/index.php
) 我希望将这种情况视为默认情况(在这种情况下,默认情况下为
mydomain.com/admin/index.php
)
I've attempted to figure this out by myself but regex
is still alien to me... 我试图自己解决这个问题,但是
regex
对我来说还是陌生的...
You can use: 您可以使用:
Options +FollowSymLinks
RewriteEngine On
// This bit redirect www.mydomain.com to mydomain.com
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L,NE]
// This bit redirects all requests to index.php if a file or directory
// bearing that name doesn't exist OR it doesn't start with /admin/
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule !^admin/ ./index.php [L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.