.htaccess 组合htaccess重定向规则
我有两个单独的htaccess,我需要将它们合并成一个,但我不知道如何做到这一点。以下是我的访问权限: 一, 我应该把它们放在同一个模块中吗?我已经试过了,但没用。.htaccess 组合htaccess重定向规则,.htaccess,url-rewriting,.htaccess,Url Rewriting,我有两个单独的htaccess,我需要将它们合并成一个,但我不知道如何做到这一点。以下是我的访问权限: 一, 我应该把它们放在同一个模块中吗?我已经试过了,但没用。 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} \ //([^\?\ ]*) RewriteRule ^ /folder/%1 [L,R=301] RewriteRule ^index\.php$ -
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \ //([^\?\ ]*)
RewriteRule ^ /folder/%1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
重新启动发动机
重写基/
重写条件%{U请求}\/([^\?\]*)
重写规则^/文件夹/%1[L,R=301]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
这样做:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# remove multiple slashes
RewriteCond %{REQUEST_URI} ^(.*?)//+(.*)$
RewriteRule ^ %1/%2 [R=302,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
重新启动发动机
重写基/
#删除多个斜杠
RewriteCond%{REQUEST_URI}^(.*)/+(.*)重写$
重写规则^%1/%2[R=302,L,NE]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.php[L]
- 在新浏览器中进行测试,以避免旧的301缓存
- 如果发生重定向循环,则打开Firebug并访问带有2个斜杠的URL,然后签入“网络”选项卡以获取重定向
NE
标志旁边添加B
标志。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \ //([^\?\ ]*)
RewriteRule ^ /folder/%1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# remove multiple slashes
RewriteCond %{REQUEST_URI} ^(.*?)//+(.*)$
RewriteRule ^ %1/%2 [R=302,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>