Log in

View Full Version : Rewrite Help


kau
02-11-2008, 09:00 PM
I need some help with mod_rewrite.

I have setup a subdomain that uses member.php

subdomain.domain.com/member.php

I want to set it up so

subdomain.domain.com/Username/

Will go to;

subdomain.domain.com/member.php?username=Username

However they will never know the member.php path. It just stays at subdomain.domain.com/Username/

I can do this using;

RewriteCond %{REQUEST_URI} ^(.*)/
RewriteRule ^([^/]*)/$ member.php?username=$1

However this presents some issues. If you hit
subdomain.domain.com/Username it errors out.

I've tried some code to add the trailing slash but it gets confused when a user name has a . in it.

Any help would be appreciated.

MiahBeSmokin420
02-11-2008, 09:06 PM
dude omg

if you can make it so lets say:

MyExampleForum.com/member.php?username=Username

if you can make it so i can get there by going to lets say:

MyOtherDomain.com/username

if you can make it so i can do that i would be willing to pay for that

Eikinskjaldi
02-12-2008, 02:49 AM
Note: none of this is tested

Try this. Don't bother with a rewrite condition.
RewriteRule ^/([^/]+)/$ member.php?username=$1

This following example may not work because I don't know if mod_rewrite supports look ahead assertions, but it is a bit more robust (it doesnt try to convert php urls)

RewriteCond %{REQUEST_URI} ^/([^./]+)/$|^/([^/]+\.(?!php($|\?))(.*))/$ [NC]
RewriteRule ^/([^/]+)/$ member.php?username=$1


MyExampleForum.com/member.php?username=Username
if you can make it so i can get there by going to lets say:
MyOtherDomain.com/username

RewriteCond %{HTTP_HOST} MyOtherDomain\.com [NC]
RewriteRule ^/(.*) http://MyExampleForum.com/member.php?username=$1 [L,R]

MiahBeSmokin420
02-12-2008, 06:17 AM
ya none of them worked but i did find a way to do it

but thanks anyways

Dismounted
02-12-2008, 08:00 AM
Where are you putting the rules?

MiahBeSmokin420
02-12-2008, 09:01 AM
if your talking to me then

here this will help you out i posted how to do it since it was not posted anywhere else here on the site and ya

here is the link

https://vborg.vbsupport.ru/showthread.php?p=1441331#post1441331

Dismounted
02-12-2008, 09:04 AM
I thought you said it DIDN'T work. I thought you weren't putting them in htaccess and in somewhere else (eg. in a plugin).

MiahBeSmokin420
02-12-2008, 09:13 AM
no the ones he posted didnt work i did a lil research and got one to work

the one that i got to work for IE and FF i posted the tutorial and all that