15
votes
How do I force SSL on Craft?
I recommend trying out the Patrol plugin. It avoids .htaccess headbanging and just handles the redirects via PHP.
Patrol Plugin for Craft CMS
In the Settings, turn on Secure Connections and add a ...
15
votes
Accepted
How do I force SSL on Craft?
For reference, this worked:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
9
votes
Accepted
Using SSL for entire website on Arcustech server
This worked for me on the Arcustech server:
Put this code in the root .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{...
9
votes
Accepted
Why am I getting ?p=oldpage in a 301 redirect?
Craft works by taking requests that normally would 404—because they don't actually exist on the server but in the database. The piece that makes this happen is the rewrite rules.
It's helpful to ...
9
votes
Accepted
Why is htaccess file not named ".htaccess" on fresh install?
Because files that start with a . are considered "hidden" by many file systems (specifically OSX default).
If the file is hidden, then there's a good chance that the user won't know about it, and won'...
7
votes
Accepted
How to remove index.php?p= permanently?
Taken from this answer on Stack Overflow:
.htaccess mod_rewrite: rewriting querystring to path
<IfModule mod_rewrite.c>
RewriteEngine On
# Remove index.php
RewriteCond %{...
6
votes
Accepted
No input file specified - [proxy_fcgi:error] Got error 'Unable to open primary script: [PATH]/html/index.php (No such file or directory)\n'
It turned out that the problem was from customizing the domain's document root in the userdata files and then the PHP-FPM configuration had not been rebuilt and the service not restarted. The ...
5
votes
How do I install Craft in shared hosting that doesn't allow index.php in a sub-folder
It's not so much that you can't have the index.php file in a subfolder that might be an issue; it is that you can't put the craft folder above your webroot. If you have access to the folder that ...
5
votes
How do I force SSL on Craft?
Try this sample htaccess-file I'm using on another site.
RewriteEngine On
RewriteBase /
# If the request is not secure
RewriteCond %{HTTPS} off
# Redirect to the secure version
RewriteRule (.*) ...
5
votes
Accepted
htaccess www to non-www redirect (and config.php)
Providing you have the necessary permissions to do this, the following in your .htaccess should do the job:
RewriteCond %{HTTP_HOST} !^domain\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://domain.co.uk/$1 [...
5
votes
redirect index.php in urls on Craft site to NEVER show index.php
As another option that I usually do in addition to .htaccess, is to also add this to the array in craft/config/general.php file, and it'll stop Craft from ever adding the index.php.
'...
5
votes
Accepted
Anyone with a tricked out .htaccess file
Been using this one for years, works great:
<IfModule mod_rewrite.c>
RewriteEngine On
# ========================================= #
# Force website to use "www"
RewriteCond %{...
4
votes
Accepted
What's the most efficient way to handle a redirect of the home page?
.htaccess should always be faster because it doesn't involve PHP or Craft at all.
But on top of that the {% redirect %} tag should be pretty darn quick.
Upon hitting it, Craft immediately calls Yii'...
4
votes
Accepted
How can I redirect HTTP to HTTPS with a local self assigned SSL certificate in my .htaccess?
The condition should be:
RewriteCond %{HTTPS} !=on
(You were missing the = sign.)
For more info, see our help article, How do I force SSL for CP requests?
4
votes
Accepted
redirect index.php in urls on Craft site to NEVER show index.php
This came up in the Craft Slack not so long ago. You'd want something like this...
# ------------------------------------------------------------
# Remove index.php
# ---------------------------------...
4
votes
Accepted
htaccess www to non-www with subdomain
This question comes close but implementing with a subdomain doesn't work.
It should work as long as you modify the rewrite rule to account for the subdomain:
RewriteCond %{HTTP_HOST} !^foo\.bar\.com$...
4
votes
Accepted
.htaccess max_execution_time
You can alter the index.php file and add [set_time_limit][1](300); anywhere below the <?php tag.
You can also try to set it by ini_set('max_execution_time', 300);
For the reason why it returns a ...
4
votes
Accepted
Cannot remove index.php from URLs either
In this case, the Apache mod_rewrite module wasn't installed, so the <IfModule mod_rewrite.c> block of Craft's default .htaccess file was being skipped not allowing index.php to be rewritten in ...
3
votes
Accepted
403 when editing the Homepage
If I understand this correctly, you can't put the /craft folder above the public root, so you put both /craft and /public inside public root? That's no point, and you need a lot more .htaccess vodoo ...
3
votes
Multi locale, multi-domain Live Preview failing
Only setting headers in .htaccess doesn't fix the problem.
As Marion Newlevant points out in her answer the cross domain works with the headers set. But you still get a white page as a preview.
...
3
votes
Restrict control panel by ip address?
If you're looking to only allow certain IP addresses to access the entire control panel, you're best bet would be to whitelist them via an .htaccess file.
Something like:
<Limit GET POST>
...
3
votes
Accepted
Return to specific locale based on cookie?
Storing the cookie
I'd recommend using the LJ Cookies plugin...
{% do craft.lj_cookies.set('locale', craft.locale, '', '/' ) %}
Retrieving the cookie
The LJ Cookies plugin is also capable of ...
3
votes
Using SSL for entire website on Arcustech server
The second one will force SSL no matter which page you're on, including any control panel requests, which is what you're after. As mentioned in the docs, make sure that goes above Craft's default ...
3
votes
How can I use images from my live Craft Site when developing locally
You could set up your assets through Amazon S3 or another remote service then that wouldn't be a problem.
Alternatively you will need to download all the assets locally if you have relative paths /...
3
votes
Accepted
redirect on a Structure
If it's just a simple redirect, it'll be quicker to do it in .htaccess and not invoke PHP/Craft at all.
3
votes
Accepted
Using Routes to load Controller
This is indeed possible. You'll want to update your route to point to an array with and identify your controller path with the key action:
public function registerCpRoutes()
{
return array(
'...
3
votes
Accepted
Getting Wordpress 404 when accessing /craft/admin
Wordpress’ .htaccess file and Craft’s .htaccess file both use the same strategy: If the request is not pointing to a valid file or folder, rather than have Apache respond with a 404, re-route the ...
3
votes
Accepted
getUrl using my original develpment server domain
Have you checked the path of the asset source the image is in? Sounds like that might still be the old server's path.
Best practice is to use Environment-specific variables in your config file, and ...
3
votes
URL rewrites not working return Apache 404's
Those are the 2 thing you need to ensure are correct.
If .htaccess files are being ignored, you need to check to see that AllowOverride is set correctly. See http://httpd.apache.org/docs/2.4/mod/core....
3
votes
Accepted
Remove subdirectories from admin URL with .htaccess
I have Craft public files set up within subdirectories of a primary domain’s web root.
The following .htaccess rules allow for the public_html subdirectory to act as the new web root.
Is there a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
htaccess × 73redirect × 17
url × 10
craft3 × 7
apache × 7
https × 7
control-panel × 6
ssl × 6
login × 4
templating × 3
localization × 3
config × 3
error × 3
install × 3
routing × 3
index × 3
php × 2
error-message × 2
routes × 2
404 × 2
security × 2
live-preview × 2
structure × 1
image-transforms × 1
image × 1