Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Redirect to https adds "/framework/main.php?url=/" in the url


Go to End


5 Posts   3834 Views

Avatar
LoFonz

Community Member, 12 Posts

23 August 2017 at 2:17am

Edited: 23/08/2017 2:32am

Hi everyone.

I'm trying to redirect a website (let's say : http://www.mysite.com) to its https version. It works but everytime it redirects someone, the url becomes https://www.mysite.com/framework/main.php?url=/.

Is there any way to remove that "/framework/main.php?url=/" part? :/ I tried everything ..

Here's my .htaccess :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
	Order deny,allow
	Deny from all
	Allow from 127.0.0.1
</Files>

# Deny access to IIS configuration
<Files web.config>
	Order deny,allow
	Deny from all
</Files>

# Deny access to YAML configuration files which might include sensitive information
<Files *.yml>
	Order allow,deny
	Deny from all
</Files>

# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_rewrite.c>

	# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
	<IfModule mod_dir.c>
		DirectoryIndex disabled
	</IfModule>

	SetEnv HTTP_MOD_REWRITE On
	RewriteEngine On
	RewriteBase '/'

	# Deny access to potentially sensitive files and folders
	RewriteRule ^vendor(/|$) - [F,L,NC]
	RewriteRule silverstripe-cache(/|$) - [F,L,NC]
	RewriteRule composer\.(json|lock) - [F,L,NC]

	# Process through SilverStripe if no file with the requested name exists.
	# Pass through the original path as a query parameter, and retain the existing parameters.
	RewriteCond %{REQUEST_URI} ^(.*)$
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule .* framework/main.php?url=%1 [QSA]
    
</IfModule>
### SILVERSTRIPE END ###

Avatar
jaybee

Community Member, 49 Posts

26 September 2017 at 2:59pm

Did you have any luck with this?

Avatar
VPull

Community Member, 58 Posts

26 September 2017 at 11:46pm

In mysite/_config.php place the below code.

//Force SSL
Director::forceSSL();

Avatar
jaybee

Community Member, 49 Posts

27 September 2017 at 1:31am

When using:

Director::forceSSL();
Director::forceWWW();

Or htaccess conditions then going to a URL the first time it will always add "/framework/main.php?url=/" to the end

Avatar
LoFonz

Community Member, 12 Posts

27 September 2017 at 1:45am

Forgot to reply to my own post :).

It looks like the .htaccess content I've posted was the way to solve it. I guess there is some kind of browser cache (even tho I cleared them all). Or even on SS I don't know. I noticed that some browsers (I'll go deeper : some sessions on chrome ^^') were redirecting to the right URL, but my main chrome session didn't... So I left it that way and a few days later, even my session did redirect to the right URL.

So the part to add at the top of your .htaccess is definitely this :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]