TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-20-2008, 11:03 AM   #1 (permalink)
The Visitor
 
Join Date: Jul 2008
Posts: 4
Thanks: 4
Gilles is on a distinguished road
Default mod_rewrite subdomain & WordPress problem

Hey everyone,

sorry for my first post being a question, but I've been trying everything and googled everything all night.

For one of my sites, annoyed.me, I want a subdomain to redirect to a folder on the main site; for example:

wordpress.annoyed.me -> annoyed.me/?tag=wordpress

I think I've done all the required work: the wildcard dns is setup and the .htaccess is pretty much complete (I think) but it's throwing me a 500 error. Would this have something to do with WordPress?

This is my .htaccess code:
Code:
<IfModule mod_rewrite.c>

	Options +FollowSymLinks 
	RewriteEngine on

	# BEGIN Subdomain
	RewriteCond %{HTTP_HOST} !^www\.annoyed\.me$ [NC] 
	RewriteCond %{HTTP_HOST} ^([^\.]+)\.annoyed\.me$ [NC] 
	RewriteRule ^([^/]+)$ /index.php?tag=%1 [L]
	# END Subdomain

	# BEGIN WordPress
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
	# END WordPress

</IfModule>
If anyone could help me out? As far as I know, the mod_rewrite is working fine. I changed index.php?tag=%1 to tag/%1/ which then gave me a 404 error that it couldn't find the folder (with the correct naming etc ...)
Code:
[Sun Jul 20 11:55:51 2008] [error] [client 87.67.212.144] File does not exist: /home/annoyed/public_html/tag/redirect
Anyone have any clues on what could be giving me this 500 error? If you need any more information, just let me know.

EDIT: obviously, you can see the error here: http://prologue.annoyed.me (this is an actual tag, so if I would be able to fix this, it should show Prologue annoyed these people but, obviously, with http://prologue.annoyed.me)
Gilles is offline  
Reply With Quote
Old 07-20-2008, 03:01 PM   #2 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

If I understand what you want to do correctly I think you want to replace
Code:
RewriteRule ^([^/]+)$ /index.php?tag=%1 [L]
with something like this:

Code:
RewriteRule ^([^/]+)$ http://annoyed.me/?tag=%1 [R=301,L]
I haven't been able to test this out yet, but this should at least get you on the right track.
Schroder is offline  
Reply With Quote
The Following User Says Thank You to Schroder For This Useful Post:
Gilles (07-20-2008)
Old 07-20-2008, 03:18 PM   #3 (permalink)
The Visitor
 
Join Date: Jul 2008
Posts: 4
Thanks: 4
Gilles is on a distinguished road
Default

Yes, something similar... This works but the URL in the address bar is changed, something it shouldn't. When I remove the 301 redirect, it throws another 500 error.

I think it's because it conflicts with the way WordPress handles their own mod_rewrite rules...
Gilles is offline  
Reply With Quote
Old 07-20-2008, 03:32 PM   #4 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

Alright. So if someone types in wordpress.annoyed.me the address stays as wordpress.annoyed.me, but internally it is annoyed.me/?tag=wordpress?

What problems were you running into with:
Code:
RewriteRule ^([^/]+)$ /index.php?tag=%1 [L]
Schroder is offline  
Reply With Quote
The Following User Says Thank You to Schroder For This Useful Post:
Gilles (07-20-2008)
Old 07-20-2008, 03:59 PM   #5 (permalink)
The Visitor
 
Join Date: Jul 2008
Posts: 4
Thanks: 4
Gilles is on a distinguished road
Default

It was giving a 500 error... However, when I set it to redirect to a dir different from the WordPress install directory, it works fine.

My guess it has something to do with the WordPress .htaccess mod_rewrite rules? Is there maybe a way to combine the two different RewriteRules into a single one... Or would I have to add a exception to the WordPress .htaccess mod_rewrite rules?

Any suggestions are welcome :D
Gilles is offline  
Reply With Quote
Old 07-20-2008, 04:04 PM   #6 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

Sounds like your suspicions are right. I would need to play around with the wordpress .htaccess to get a better idea what exactly is causing the issue.

What error is displaying in the log when you have it as "/index.php?tag=%1"? That may shed some light on the issue.
Schroder is offline  
Reply With Quote
The Following User Says Thank You to Schroder For This Useful Post:
Gilles (07-20-2008)
Old 07-20-2008, 04:13 PM   #7 (permalink)
The Visitor
 
Join Date: Jul 2008
Posts: 4
Thanks: 4
Gilles is on a distinguished road
Default

http://prologue.annoyed.me/ - This gives you the 500 error;
Prologue annoyed these people - This is the page it should display.

It finds the page since it doesn't throw a 404 error. Appearantly, the .htaccess does something with the url which cuases it to give a 500 error.

I'm clueless tbqh.

I've tried to make them not clash, but no luck from the looks of it... My current .htaccess file:
Code:
<IfModule mod_rewrite.c>
 
	RewriteEngine on
	RewriteBase /

	# BEGIN Redirect www to non-www
	RewriteCond %{HTTP_HOST} ^www\.annoyed\.me$
	RewriteRule (.*) http://annoyed.me/$1 [R=301,L]
	# END Redirect www to non-www


	# BEGIN WordPress
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{HTTP_HOST} !^([^\.]+)\.annoyed\.me$ [NC] 
	RewriteRule . /index.php
	# END WordPress


	# BEGIN Subdomain
	RewriteCond %{HTTP_HOST} ^([^\.]+)\.annoyed\.me$ [NC] 
	RewriteRule ^([^/]+)$ /index.php?tag=%1 [L]
	# END Subdomain

</IfModule>
The first set of rules have just been added, to redirect What is annoying you today? to annoyed.me.

If anyone could help me out, let me know! I am willing to compensate you!

Last edited by Gilles : 07-20-2008 at 05:22 PM.
Gilles is offline  
Reply With Quote
Old 07-20-2008, 05:23 PM   #8 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

The problem I can see with the .htaccess rule below is that the system is trying to accessing "/tag/redirect" instead of passing it through the wordpress system.

Code:
RewriteRule ^([^/]+)$ /tag/%1/index.php?tag=%1 [L]
I wasn't able to recreate this through a slightly modified rule (I used ^(.*)$ instead of ^([^/]+)$). ^([^/]+)$ did not work for me at all, which may be because I was testing it with a subdirectory instead of a subdomain.

If "/index.php?tag=%1" is causing a 500 error as well I'm curious what error is being recorded in the error log.

Besides that I think I'm as stumped as you are. Hopefully someone else has a solution they can post.
Schroder is offline  
Reply With Quote
The Following User Says Thank You to Schroder For This Useful Post:
Gilles (07-20-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:01 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design