7 Replies - 394 Views - Last Post: 20 March 2018 - 01:48 PM

#1 Foobarer   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 263
  • Joined: 28-March 17

Redirect from base URL to specific subfolder

Posted 18 March 2018 - 09:04 AM

I just uploaded my website.
My website has no files in the base, except for .htaccess,
So I added this line on .htaccess: "Options -Indexes" to prevent access to the root folder.
Now I want to also redirect users from base to a specific folder on landing so if they land on mysite.com, the should be redirected to mysite.com/path

Do I do that with .htaccess? Or a PHP redirect? Or maybe I copy 1 folder content to the base instead?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Redirect from base URL to specific subfolder

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14495
  • View blog
  • Posts: 58,109
  • Joined: 12-June 08

Re: Redirect from base URL to specific subfolder

Posted 18 March 2018 - 09:19 AM

What's the reasoning for having the site inside a folder in root and not just in the root?
Was This Post Helpful? 1
  • +
  • -

#3 Foobarer   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 263
  • Joined: 28-March 17

Re: Redirect from base URL to specific subfolder

Posted 18 March 2018 - 12:40 PM

Because I divided the site to languages, so there are multiple languages, each in its own folder
Should I just copy a single language to the root?

But how can I still redirect?
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2158
  • View blog
  • Posts: 6,543
  • Joined: 15-January 14

Re: Redirect from base URL to specific subfolder

Posted 19 March 2018 - 10:46 AM

You can redirect using htaccess.
Was This Post Helpful? 1
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14495
  • View blog
  • Posts: 58,109
  • Joined: 12-June 08

Re: Redirect from base URL to specific subfolder

Posted 19 March 2018 - 10:48 AM

Seems odd you would have complete copies of the site in different languages. Have you considered a more CMS approach where the content is store in the database.. there's only one file structure.. and getting the data sends in a language key to get different translations stored in the db?
Was This Post Helpful? 1
  • +
  • -

#6 Foobarer   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 263
  • Joined: 28-March 17

Re: Redirect from base URL to specific subfolder

Posted 20 March 2018 - 12:50 AM

View PostArtificialSoldier, on 19 March 2018 - 10:46 AM, said:

You can redirect using htaccess.


What htaccess command do I put in the .htaccess file? I've tried multiple but the only one works is Options -Indexes that prevent users from going to the root folder. But all others I've found online didn't work to redirect users to a specific one.
I want them to land at mydomain.com/en - You know what is the redirect command?


View Postmodi123_1, on 19 March 2018 - 10:48 AM, said:

Seems odd you would have complete copies of the site in different languages. Have you considered a more CMS approach where the content is store in the database.. there's only one file structure.. and getting the data sends in a language key to get different translations stored in the db?



Some of my data is in DB, and I change it using Javascript.
Also, one of the languages is RTL and the other is English and it just causes too much problems with the view so I had to actually change HTML parts.

Also, I barely ended PHP / HTML tutorial on YouTube / W3Schools (And still learning new things while forgetting older all the time) - Just to give you an idea of what kind of newbie I am to this.

This post has been edited by Foobarer: 20 March 2018 - 12:53 AM

Was This Post Helpful? 0
  • +
  • -

#7 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2158
  • View blog
  • Posts: 6,543
  • Joined: 15-January 14

Re: Redirect from base URL to specific subfolder

Posted 20 March 2018 - 10:58 AM

Quote

But all others I've found online didn't work to redirect users to a specific one.

Well, if literally all others you've found online didn't work, then maybe your server disables or doesn't support them. If you search for Apache redirects I'm sure that the most popular ways will be in the first results you find, so if those don't work then your server must not support it. Ask your host how they want you to do it.
Was This Post Helpful? 1
  • +
  • -

#8 Foobarer   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 263
  • Joined: 28-March 17

Re: Redirect from base URL to specific subfolder

Posted 20 March 2018 - 01:48 PM

will check and will also try on a newly installed server
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1