Reputation: 1235
I'm using Codeigniter with the standard .htaccess rewrite rules so that no /index.php/ is visible within the urls.
Now I recently needed to take the site down temporarily and therefore wanted to redirect everyone to a 'down' page. The following worked:
$route['default_controller'] = "down";
$route['(:any)'] = "down";
But I'm aware that in this case, a 301 is really appropriate.
How and where should I set that? I don't see a way to specify it in the routes.php and was confused about how to do it within the .htaccess because of the existing rules....
RewriteBase /
RewriteCond %{REQUEST_URI} ^_system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^myapp.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond $1 !^(index\.php|resources|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
Upvotes: 0
Views: 363
Reputation: 143906
You don't want a 301 redirect. 301 means "Permanent", and this should only be a temporary redirect. And you can do this with htaccess if you add this above all your other rules:
RewriteRule ^ /down.html [L,R=302]
As long as it's above any of the other rules, then any request will get redirected to /down.html
. If you don't want to externally redirect the browser (e.g. have the /down.html
URL show up in the URL address bar), then remove the ,R=302
bit from the square brackets and the URL address bar would stay unchanged while the content served is from down.html.
Upvotes: 1