Forum Moderators: phranque

Message Too Old, No Replies

need help with subdomain rewrite with multiple rules

subdomain rewrite multiple rules

         

sporb

4:53 am on May 17, 2007 (gmt 0)

10+ Year Member



i am rewriting a subdomain but i can't get multiple rules to work...

right now my.domain.com is rewritten to use 'my' as a variable.. everything works fine, but if i try to make another rule such as my.domain.com/view/99/ the other rules do not work. this is my current rewrite:

rewriteEngine On
rewriteCond %{REQUEST_URI}!^/index\.php
rewriteCond %{HTTP_HOST}!^www\.
rewriteCond %{HTTP_HOST} ^(.+)\.domain\.com

rewriteRule .* /index.php?v=%1 [L]
rewriteRule ^/(view)/([0-9]+)/?$ view.php?v=%1&a=$2 [L]

-eof

i tried to move the first rule under the second rule but i get a 500 error. any help is much appreciated!

jdMorgan

3:21 pm on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteConds apply only to the first RewriteRule that follows them. Does that change the way you look at your problem?

For use in /.htaccess:


RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.+domain\.com
RewriteRule ^view/([0-9]+)/?$ view.php?v=%1&a=$1 [L]
#
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.+domain\.com
RewriteRule !^(index¦view)\.php$ /index.php?v=%1 [L]

Replace the broken pipe "¦" character in the second rule's pattern with a solid pipe character before use; Posting on this board modifies the pipe character.

Jim