1
studioC
http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url using .htaccess
  • 2005/8/9 8:52

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


if you want to set a standard domain.

the following entry in your .htaccess :

RewriteEngine on
RewriteCond %{HTTP_HOST} !^domain\.com$
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

will redirect to http://domain.com

happy xoopsing
michael

2
studioC
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url
  • 2005/8/9 8:56

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


uups.. forgot another ..

ErrorDocument 404 index.php


in your .htacces will redirect if page is not found. Of course you can make your own error page and redirect to this instead of index.php .

http://xoopsfactory.com/balalalal


michael

3
Shine
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url
  • 2005/8/9 10:40

  • Shine

  • Just can't stay away

  • Posts: 822

  • Since: 2002/7/22


Hi Studio,

Could you please give a full (code file) example in how to realise them both? (redirect and errorpage) And where to put the .htacces and other related files exactly?

Thanks in advance,
grtz., Shine

4
studioC
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 11:09

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


hello shine

Please test the following on a testdomain or a test directory to ensure everything is working as intended.
before playing with .htaccess files please ensure that mod_rewrite is enabled on your server and on your Web.

In my case i had to edit config file of that web but that's jut me??

Options +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All



When your web is allowed to use mod_rewrite open an editor and type:
ErrorDocument 404 errordocument.html

RewriteEngine on
RewriteCond 
%{HTTP_HOST} !^domain.com$
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

and save file as ".htaccess"

do not forget to replace domain.com with your domain.tld and replace name of errordocument.html to your needs.

- upload .htaccess to your root of domain
- upload an errordocument to your root of domain (in this case errordocument.html)

in case of xoopsfactory i placed an errordocument within a contentmodul and I put in my .htaccess the following line to redirect 404

ErrorDocument 404 http://xoopsfactory.com/modules/information/xoops-factory-error-document-404.php



cheers
michael

edit:


if there are problems after uploading, you should delete that .htacces file from ftp and check again. Remember that some ftp clients do not show hidden files like .htacces. check for an option to make them visible!

5
marcan
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 11:32

  • marcan

  • Just can't stay away

  • Posts: 824

  • Since: 2003/10/8


Yep, that's ity Michael. I just copied your code in the htaccess file of SmartFactory and it works perfectly.

Thanks !
.:: marcan (aka mal aka Marc-André) ::.
.:: Open Source :: The SmartFactory ::.
.:: XOOPS Professional Services :: INBOX International ::.

6
marcan
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 14:23

  • marcan

  • Just can't stay away

  • Posts: 824

  • Since: 2003/10/8


And the 404 redirect is also very cool ! Have a look : http://smartfactory.ca/anypage

Thanks Michael !
.:: marcan (aka mal aka Marc-André) ::.
.:: Open Source :: The SmartFactory ::.
.:: XOOPS Professional Services :: INBOX International ::.

7
McNaz
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 14:29

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


Quote:
And the 404 redirect is also very cool ! Have a look : http://smartfactory.ca/anypage


Very Uber!! Nice!!

8
studioC
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 18:53

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


Yes, there may appear some problems with subdomains if you route a subdomain into a folder within (below) your web root.

I just spoke with marcan who reported this problem. From here it's not a problem cause i'm a) normally driving subs in their own web or b) havin folders for domains and subs which does not effect each other.

So, again. take care and test first!
michael

9
studioC
Re: http://xoopsfactory.com -or- http://www.xoopsfactory.com - setting a standard-url by .htaccess
  • 2005/8/9 18:58

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


for those of you who might think, why the hell this guy wants to have an url without www

- i think the age of naming domains "www" is not neccessary today and is a bit out of date
- i mentioned some shared link popularity on http://xoopsfactory.com and http://www.xoopsfactory.com each and of course i want to concentrate this on one domain
- i always begin new projects defining a standard domain

happy xoopsing
michael

Login

Who's Online

213 user(s) are online (117 user(s) are browsing Support Forums)


Members: 1


Guests: 212


Mamba,

more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits