没有重写特定文件夹 - htaccess

时间:2022-03-18 11:04:41

My current .htaccess-File looks like this:

我当前的.htaccess-File看起来像这样:

RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/?$ index.php?g=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?g=$1&pt=$2 [L,QSA]

There is the physical folder install.

有物理文件夹安装。

If I try to open http://example.com/install instead of opening the install/index.php it tries to open index.php?g=install. No wonder here, because, thats what I wanted. But how can I still open the install-Folder. Everything go to index, but install go to install ...

如果我尝试打开http://example.com/install而不是打开install / index.php,它会尝试打开index.php?g = install。难怪这里,因为,这就是我想要的。但是我怎么还能打开install-Folder。一切都去索引,但安装去安装...

I tried something like this: RewriteRule ^install/index\.php$ /install/index.php [R=301,L,NC]

我试过这样的事情:RewriteRule ^ install / index \ .php $ /install/index.php [R = 301,L,NC]

Still not working.

还是行不通。

Any Ideas?

有任何想法吗?

1 个解决方案

#1


1  

Create a bypass rule for /install/ URI:

为/ install / URI创建绕过规则:

RewriteEngine On
RewriteBase /folder/

# skip /install/ from rules below
RewriteRule ^install/?$ - [L,NC]

# skip all directories and files from rewrites
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# handle single level virtual folder 
RewriteRule ^([^/]+)/?$ index.php?g=$1 [L,QSA]

# handle 2 level virtual folders 
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?g=$1&pt=$2 [L,QSA]

#1


1  

Create a bypass rule for /install/ URI:

为/ install / URI创建绕过规则:

RewriteEngine On
RewriteBase /folder/

# skip /install/ from rules below
RewriteRule ^install/?$ - [L,NC]

# skip all directories and files from rewrites
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# handle single level virtual folder 
RewriteRule ^([^/]+)/?$ index.php?g=$1 [L,QSA]

# handle 2 level virtual folders 
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?g=$1&pt=$2 [L,QSA]