Forum Moderators: phranque

Message Too Old, No Replies

virtual directory

         

squallions

6:32 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



This is my current .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.net
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^forum.html forum.php [L,NC]
RewriteRule ^index.html index.php [L,NC]
RewriteRule ^lyric.html lyric.php [L,NC]
RewriteRule ^vtopiclast([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?p=$1&highlight=$2 [L,NC]
RewriteRule ^vtopiclast([0-9]*).* viewtopic.php?p=$1 [L,NC]
RewriteRule ^viewpoll([0-9]*)-([0-9]*)-([a-zA-Z]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&vote=viewresult [L,NC]
RewriteRule ^vtopic([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?t=$1&highlight=$2 [L,NC]
RewriteRule ^vtopic([0-9]*).html&view=newest viewtopic.php?t=$1&view=newest [L,NC]
RewriteRule ^vtopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L,NC]
RewriteRule ^vtopic([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2 [L,NC]
RewriteRule ^vtopic([0-9]*).* viewtopic.php?t=$1 [L,NC]
RewriteRule ^vtopic([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L,NC]
RewriteRule ^404.html misc.php?xtra=404 [L,NC]
RewriteRule ^403.html misc.php?xtra=403 [L,NC]
RewriteRule ^400.html misc.php?xtra=400 [L,NC]
Options -Indexes
ErrorDocument 403 /403.html
ErrorDocument 401 /v-web/errdocs/401.html
ErrorDocument 500 /v-web/errdocs/500.html
ErrorDocument 400 /400.html
ErrorDocument 404 /404.html

I want to add a virtual directory so that when user goto

http://www.mysite.net/3
it would be known as
http://www.mysite.net/profile.php?mode=viewprofile&u=3

I have tried

RewriteRule ^/([0-9]*) profile.php?mode=viewprofile&u=$1 [L]
after the 400.html misc.php?xtra=400 but it doesn't work.

Also, tried add "RewriteBase /" that I found on some website but still doesn't work.

Anyone has any idea? Thank you.

Caterham

8:58 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



You have to remove the beginning slash in per-dir rewriting (.htaccess).

You won't need a RewriteBase unless you use an alias with mod_alias.

RewriteRule ^([0-9]+)/? profile.php?mode=viewprofile&u=$1 [L]

Robert

squallions

9:37 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



That's awsome.
Thank alot!

squallions

3:53 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



umm .. one more question

I like to rewrite

http://www.mysite.net/3/p2
to
http://www.mysite.net/profile.php?mode=viewprofile&u=3&page=2

RewriteRule ^([0-9]+)/p([0-9]+)/? profile.php?mode=viewprofile&u=$1&page=$2 [L]
seem not to work :(

And also, rewrite

http://www.mysite.net/3/whatever here except p2 above
still go to
http://www.mysite.net/profile.php?mode=viewprofile&u=3

because when i try to go to [mysite.net...] .. my image was broken because it looks into [mysite.net...]

Thanks.

jdMorgan

4:30 pm on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The images are probably broken because your script generates code that refers to them using a relative URL-path.

Instead of using
<img src="blah.gif">
you'll need to use
<img src="/blah.gif">

This causes the browser to look for the image relative to the DocumentRoot, rather than relative to where it thinks the script is running.

Jim

squallions

6:30 am on Jan 15, 2005 (gmt 0)

10+ Year Member



Yeah. But to go back and fix all the img tag is ... a pain :(

Please help with the rewrite above.