.htaccess 重写 - 重定向页面
.htaccess rewrite - redirect pages
我想知道如何重定向访问以下地址的所有访问者:
https://example.com/anypage to https://example.com/search/anypage
它无法重定向已经在 https://example.com/search/anypage 的人以避免循环。这是我当前的 .htaccess:
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
谢谢
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} !/search/ [NC]
RewriteRule ^(.*)$ search/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
我想知道如何重定向访问以下地址的所有访问者:
https://example.com/anypage to https://example.com/search/anypage
它无法重定向已经在 https://example.com/search/anypage 的人以避免循环。这是我当前的 .htaccess:
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
谢谢
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} !/search/ [NC]
RewriteRule ^(.*)$ search/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>