I managed to let http://forum.domain.com/ to go to http://www.domain.com/forum/ ... but i want everything after http://forum.domain.com/ to go to a specific file and call a script.
An example would be:
http://forum.domain.com/test/ would to go www.domain.com/forum/?query=test .
My problem is when i go to http://forum.domain.com/test it sends me to http://forum.domain.coim/test/?query=test
( On a sidenote: http://forum.domain.com/test/test2/ should go (silently ofc) to www.domain.com/forum/?query=test/test2/ )
When i go to http://forum.domain.com/test/ the script works just fine.
This is why i'd like to add a trailing slash to the end but only if it doesnt end with a trailing slash allready.
So http://forum.domain.com/test should go to http://forum.domain.com/test/ before it gets send to www.domain.com/forum/?query=test (silent redirect)
Could anyone help me out? I'm using the following code:
- Code: Select all
Options +FollowSymLinks +Indexes
#ErrorDocument 404 /notfound/index.php
RewriteEngine On
# Loop stopping code.
RewriteCond %{ENV:REDIRECT_STATUS} !^$
RewriteRule ^ - [L]
# Forward to root
RewriteCond %{HTTP_HOST} ^www\.domain.\com$ [NC]
RewriteRule ^(.*)$ /$1 [QSA,L]
#force www
RewriteCond %{HTTP_HOST} ^domain.\com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
# Display news /news/id/
#RewriteRule ^news/([0-9]+)/$ /news/viewnews.php?id=$1 [NC,L]
# Display an error /error/errortag/
#RewriteRule ^error/([a-z]+)/$ /errors/displayError.php?error=$1 [NC,L]
# Logout by visiting this link /logout/
#RewriteRule ^logout/$ /logout.php [NC,L]
# Forward to browse
RewriteCond %{HTTP_HOST} ^browse\.domain.\com$ [NC]
RewriteRule ^(.*)$ /browse/$1 [QSA,L]
# Forward to news
RewriteCond %{HTTP_HOST} ^news\.domain.\com$ [NC]
RewriteRule ^(.*)$ /news/$1 [QSA,L]
# Forward to forums
#RewriteCond %{HTTP_HOST} ^forum\.domain.\com$ [NC]
#RewriteRule ^(.*)$ /forum/$1 [L]
# Forward to forums
RewriteCond %{HTTP_HOST} ^forum\.domain.\com$ [NC]
RewriteRule ^(.*)$ /forum/index2.php?query=$1 [QSA,L]
# Forward to statistics
RewriteCond %{HTTP_HOST} ^stats\.domain.\com$ [NC]
RewriteRule ^(.*)$ /statistics/$1 [QSA,L]
# Forward to static
RewriteCond %{HTTP_HOST} ^static\.domain.\com$ [NC]
RewriteRule ^(.*)$ /static/$1 [QSA,L]
# Forward to account
RewriteCond %{HTTP_HOST} ^my\.domain.\com$ [NC]
RewriteRule ^(.*)$ /account/$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^my\.domain.\com/settings/$ [NC]
RewriteRule ^(.*)$ /account/settings/$1 [QSA,L]
# Forward every other subdomain to users
RewriteCond %{HTTP_HOST} ^(.+)\.domain.\com$ [NC]
RewriteRule ^(.*)$ /users/?name=%1 [L]
It's concerning the following chuck of code which is listed above:
- Code: Select all
# Forward to forums
RewriteCond %{HTTP_HOST} ^forum\.domain.\com$ [NC]
RewriteRule ^(.*)$ /forum/index2.php?query=$1 [QSA,L]