Jump to content



Photo

Help. Apache mod_rewrite

apache mod_rewrite

  • Please log in to reply
3 replies to this topic

#1 AStaley

AStaley

    Neowinian

  • Tech Issues Solved: 4
  • Joined: 07-August 04
  • Location: United Kingdom
  • OS: Windows 8.1 Pro x64, OSX Mavericks, Elementary OS, Server 2008 R2/2012 R2, CentOS.
  • Phone: iPhone 4 (IOS7.1.1)

Posted 29 April 2013 - 11:39

Hi, I'm in the process of setting up my first web server to be used in house partly as a training exercise for myself, but also to host a company forum/wiki.

The server is running CentOS6 using the minimum setup so no GUI. Apache was loaded via yum and is 2.2.15. I've also loaded and have running phpBB along with the required pre-requisites. Later I intend to load MediaWiki (we've been using Screwturn wiki, loaded on a Windows box).

Currently phpBB is access via http://forum.mydomain.com/forum, but I would like to set it up so that you can simply type "forum.woodgate-clark.co.uk" to get to the page. It would seem that I can do this within Apache using the mod_rewrite technique but after having read (and clearly, not understood) the page on the Apache site I still can't get it to work. I've enabled "AllowOverride All" within the httpd.conf file and created a .htaccess file within /var/www/html directory, but I'm struggling after that.

Thanks in advance.


#2 sean.ferguson

sean.ferguson

    Anonymous

  • Joined: 25-June 05
  • Location: Scotland
  • OS: GNU/Linux

Posted 29 April 2013 - 18:13

You will need to define your virtual hosts within the httpd.conf file.

I cant remember exactly the formating but something like this should work. Append it to the end of the file.

<VirtualHost *>
	DocumentRoot "/var/www/forum/"
	ServerName forum.domain.co.uk
	ServerAdmin webmaster@domain.co.uk
	ErrorLog /var/log/apache2/forum.log

	<Directory /var/www/forum/>
		Options Indexes FollowSymLins MultiViews +Includes
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
</VirtualHost>

Something to that effect should work i believe :)

Edit: Sorry just to add to that, when you add your wiki etc you will need to define a new VirtualHost. So just add another block to the end of the httpd.conf

<VirtualHost *>
	DocumentRoot "/var/www/forum/"
	ServerName forum.domain.co.uk
	ServerAdmin webmaster@domain.co.uk
	ErrorLog /var/log/apache2/forum.log

	<Directory /var/www/forum/>
		Options Indexes FollowSymLins MultiViews +Includes
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
</VirtualHost>

<VirtualHost *>
	DocumentRoot "/var/www/wiki/"
	ServerName wiki.domain.co.uk
	ServerAdmin webmaster@domain.co.uk
	ErrorLog /var/log/apache2/wiki.log

	<Directory /var/www/wiki/>
		Options Indexes FollowSymLins MultiViews +Includes
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
</VirtualHost>


Something like that ;)

Edited by sean.ferguson, 29 April 2013 - 18:18.


#3 OP AStaley

AStaley

    Neowinian

  • Tech Issues Solved: 4
  • Joined: 07-August 04
  • Location: United Kingdom
  • OS: Windows 8.1 Pro x64, OSX Mavericks, Elementary OS, Server 2008 R2/2012 R2, CentOS.
  • Phone: iPhone 4 (IOS7.1.1)

Posted 01 May 2013 - 15:49

Sorry for the late reply. This was exactly what I was looking for and works perfectly.

#4 sean.ferguson

sean.ferguson

    Anonymous

  • Joined: 25-June 05
  • Location: Scotland
  • OS: GNU/Linux

Posted 01 May 2013 - 17:00

You're welcome, and just for anyone else visiting this thread for advice due to my laziness and use of copy/paste, FollowSymLins should in fact be FollowSymLinks.

:)



Click here to login or here to register to remove this ad, it's free!