Author Topic: An issue with slash  (Read 318 times)

happy

  • Prime Member
  • ****
  • Posts: 148
  • Karma: +0/-1
An issue with slash
« on: January 10, 2018, 05:29:41 AM »
Hi

I have a folder in root like 'premium-members'

now when i open site like https://www.website.com/premium-members

it takes to this page https://www.website.com/info.php

whereas when i open site like https://www.website.com/premium-members/

it takes to correct page

what i want url should take to correct page whether slash is added or not at the end of url

Please guide

Thanks

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3119
  • Karma: +210/-7
    • Maverick Webworks
Re: An issue with slash
« Reply #1 on: January 10, 2018, 10:15:47 AM »
The problem could be that your host doesn't have 'DirectorySlash On' enabled which automatically adds the slash to a directory url.

If this is the case you can try adding the following to your HTACCESS file to create a rewrite and redirect to force the trailing slash to always be added.

First make sure that the following is added to the top of the htaccess file.
# DirectoryIndex controls which file is chosen as the default page in a directory
# The Options -Indexes prevents a list of files from being shown in a directory
Code: [Select]
DirectoryIndex index.html index.php
Options -Indexes

Then include the following:
Code: [Select]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/premium-members/?$ https://website.com/premium-members/ [R=301,L]

If your Etano script is installed in a subdirectory on your server and the above code doesn't seem to work then you might also need to include a RewriteBase statement, like so:
Code: [Select]
RewriteBase /premium-members
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/premium-members/?$ https://website.com/premium-members/ [R=301,L]

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

happy

  • Prime Member
  • ****
  • Posts: 148
  • Karma: +0/-1
Re: An issue with slash
« Reply #2 on: January 11, 2018, 12:28:12 AM »
Thanks for your reply

But i have around 50 folders please give me a solution without adding folder name.

Thanks

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3119
  • Karma: +210/-7
    • Maverick Webworks
Re: An issue with slash
« Reply #3 on: January 11, 2018, 03:05:25 AM »
I really don't have enough info to provide advice for this.

Why do you have it in a subdirectory in the first place?

If it's because you running another site in the main root directory and you're running multiple sites in different subdirectories under the same domain, then you have a problem because if you use htaccess to do a rewrite so the folder name is removed it will be redirected to using the main domain name which will potentially cause all kinds of issues and confusions, including your visitors and Google as they will see your main domain site and the site running in the subdirectory as being the same site.

If you're running different sites under the same domain in subdirectories (folders), you're far better off keeping the subdirectory name and create folder names that would be relevant to the content and something your visitors can identify with, and are a keyword(s) that Google will like which could actually be beneficial for SEO purposes.

If you don't have any other sites or scripts running in your main root directory, move the script out of the subdirectory into the main directory, this is simplest and best solution as it won't create excess bloat of doing a bunch of redirects and will be better for SEO.

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.