Jump to content

Adding a trailing slash (well ... kind of...)


adrianTNT

Recommended Posts

Hello.

 

I have a domain that I use for domain parking, let's say parking.com, in root of this site I have a folder "domains" and I will keep all content of my parked domains inside this folder: phisical directory structure is:

parking.com/domains/somesite.com/

parking.com/domains/someothersite.com/

 

I am doing this by htaccess so that by accessing some-site.com it will show the content of parking.com/domains/some-site.com

I have a trailing slash problem with my code:

If I enter in browser somesite.com/sample/ it works ok but if I enter somesite.com/sample it redirects incorrectly in address bar, it goes to http://somesite.com/domains/somesite.com/sample/ but shows correct content though.

Is there  a way to maybe redirect somesite.com/sample to somesite.com/sample/ ?

 

My htaccess, ady advices/fixes are welcome:

 

RewriteCond %{HTTP_HOST}	!parking.com
RewriteCond %{HTTP_HOST}	!208.109.209.xx
RewriteCond $1 !^domains

# with or without www redirect to a  folder without www
RewriteCond %{HTTP_HOST}	^(www.)?([^.]*)\.(.*)$ [NC]
RewriteRule ^(.*)$			/domains/%2.%3/$1 [L,QSA]

# redirect to index without any "if file exists" exception, otherwise root "/" exists and directory list will be printed ?!
RewriteRule ^domains/([^/]*)/$ /domains/?domain=$1

# allow for existent files, redirect otherwise
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^domains/([^/]*)/(.*)$ /domains/?domain=$1&page=$2 [L,QSA]

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.