Link to home
Create AccountLog in
Avatar of peps03
peps03

asked on

Prevent page from loading without the trailing slash

Hi,

I have a cms page in a folder of the domain bbb.com. url: http://bbb.com/cms/ (works fine)

The problem is, when i type http://bbb.com/cms [without the trailing slash], i'm taken to the page:
http://aaa.com/bbb.com/cms(/)
This happens because aaa.com is my main domain name, and bbb.com is an other domain name. .htaccess however redirects requests to the bbb.com domain to the bbb.com folder correctly.

So now i'm trying to figure out how to prevent this page: http://aaa.com/bbb.com/cms(/) from loading because i forces a double login issue.

I've tried auto adding the trailing slash through .htaccess
I've tried a .htaccess redirect from http://bbb.com/cms to http://bbb.com/cms/

No success, i keep ending up at this page: http://aaa.com/bbb.com/cms(/)

How can i fix this?

Thanks a lot!
Avatar of mattibutt
mattibutt
Flag of United States of America image

hi
this is dependant on how you are rewriting urls if you are you will need to modify your htaccess file if thats how cms is setup also have you got a setting in your cms where you define application url if thats the case then you need to modify this php settings file where you might see defined url
Avatar of peps03
peps03

ASKER

Hi Mattibutt,

Thanks for your reaction!

I have this in the .htaccess:

RewriteCond %{HTTP_HOST} ^bbb.com$
RewriteCond %{REQUEST_URI} !^/bbb.com/
RewriteRule (.*) /bbb.com/$1

rewritecond %{http_host} ^www.bbb.com [nc]
rewriterule ^(.*)$ http://bbb.com/$1 [r=301,nc]

The cms doesn't have any url setting or what so ever.

The goal is preventing http://aaa.com/bbb.com/cms(/) from being loaded.

thanks!
what is the web server you are using IIS or Apache also check whether apache re-write module is enabled

put the following codes above your htaccess file in the beginning of the file
RewriteBase /
RewriteEngine on
Avatar of peps03

ASKER

apache

RewriteBase /
RewriteEngine on
is in it, the actual .htaccess is much bigger.
if its already there then take it out and try and post back
Avatar of peps03

ASKER

What?
leave this:
RewriteBase /
RewriteEngine on

out of the .htaccess file?

then this:
RewriteCond %{HTTP_HOST} ^bbb.com$
RewriteCond %{REQUEST_URI} !^/bbb.com/
RewriteRule (.*) /bbb.com/$1

rewritecond %{http_host} ^www.bbb.com [nc]
rewriterule ^(.*)$ http://bbb.com/$1 [r=301,nc]

will never work
it all depends where you are hosting if its your own server and not shared it wont need that if rewrite module in httpd.conf file is already on
Avatar of peps03

ASKER

its @ a server @ a hosting provider

But all i want to do is prevent http://aaa.com/bbb.com/cms(/) from being loaded.

try rewrittin url
RewriteRule ^cms$ cms/
Avatar of peps03

ASKER

nope, no succes.

it returns: http://aaa.com/bbb.com/cms/ (with the slash)
what is cms file extension?
if cms is .html then do the following however if its php then provide extension in the code
RewriteRule ^cms$ cms.html
Avatar of peps03

ASKER

The cms file is index.php
ASKER CERTIFIED SOLUTION
Avatar of mattibutt
mattibutt
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of peps03

ASKER

Thanks mattibutt!

I try this tomorrow. Must get some sleep now, so you're right, you'll hear from me later!
Avatar of peps03

ASKER

Thanks mattibutt!

This did the trick! Great!