Jump to content

Recommended Posts

The question mark is a regular expression special character, to match it literally you will have to escape it. That's certainly the case if you were using a PCRE function, I assume the .htaccess regex engine is similar.

 

^([^/.]+)/\?$ 

im not great on htaccess ...infact i know pritty much nothing lol

 

my file looks liek this

 

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

 

RewriteRule ^([^/.]+)/?$ members/index.php?page=profile&username=$1

 

 

am i right by saying i need to chnage this then?

The question mark is a regular expression special character, to match it literally you will have to escape it. That's certainly the case if you were using a PCRE function, I assume the .htaccess regex engine is similar.

 

^([^/.]+)/\?$ 

the question mark in question,  /? is stating that the new URL can end with or without a forward slash, and therefore, does not need to be escaped.

going back to your original post:

 

with the code above it displays /runnerjp?m=10&y=09

 

and then you proceed to say how when you change the query string it "doesnt show".

 

does the querystring, when formatted:

/runnerjp?m=10&y=09

work for you?  is there even a problem at hand?

 

thing is, you have RewriteRule's in place, but aren't actually using them .. thus, confusing yourself in the code.  reconsider your need for rewrite's.

dang ...sop what is the matter with it??  if i type in manually into the url address bar http://www.runningprofiles.com/members/Admin&m=6&y=2009 it works great but when i try run it via the script like this <a href="<?php echo  $puser; ?>&m=<?php=(($m-1)<1) ? 12 : $m-1 ?>&y=<?php =(($m-1)<1) ? $y-1 : $y ?>"> it wont show the variable of $puser... if i saw the & with ? it will show it but the script wont pick up m=

i must note if i do this

 

<a href="<? echo  $puser; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>">

i get

 

http://www.runningprofiles.com/members/Admin?m=9&y=2009

 

and what is wrong with that?  that looks right .. it has your username, the month and the year all there.  why doesn't that work for ya?

Forgive my ignorance but I still don't see your objective. You appear to be saying you wish to URL forward /members/?m=9&y=2009 to /members/index.php?page=profile&username=something which to me makes no sense at all.

 

A standard example I would expect to see mod_rewrite employed for...

 

Take http://www.example.com/members/john/ and redirect to http://www.example.com/members.php?name=john

 

The main reason to use mod_rewrite is to avoid having GET attributes in the URL.

 

 

ok sorry... basicly i have a calander within my profile page... and for the calander to select previous or coming up months i need to have m=? within the url  so m is month and the number 1-12 represents the month needed to be selected. thats why im using m=... obviusly when a user 1st goes on the page the current month is selected within the code and m= is not needed.

 

mrMarcus when i use that code for some reaosn my $_get wont grab the m= :S no idea why

k, try this (untested):

 

RewriteRule ^([^/.]+)/([0-9])/([0-9])/?$ members/index.php?page=profile&username=$1&month=$2&year=$3

 

this will now create a URL like so:

 

http://www.runningprofiles.com/members/Admin/9/2009/

 

now, feel free to use $_GET['month'] and $_GET['year'].

 

let me know how that pans out.

Ok, I understand that you wish to pass date and month, but it appears you've chosen to do this in the form of ?m=10&y=2009 which is fine, but where does mod_rewrite come into it? Are you attempting to merge that functionality with a mod_rewrite on username?

 

For example trying to rewrite...

http://www.example.com/members/john/?m=10&y=2009

to

http://www.example.com/index.php?page=members&m=10&y=2009

 

EDIT: Looks like mrMarcus came to a similar conclusion... Try adding a forward slash before members to make sure the base is correct (ie RewriteRule ^([^/.]+)/([0-9])/([0-9])/?$ /members/index.php?page=profile&username=$1&month=$2&year=$3

my bad.

 

try replacing what i gave you with this:

 

RewriteRule ^([^/.]+)/([0-9]+)/([0-9]+)/?$ members/index.php?page=profile&username=$1&month=$2&year=$3 [NC,L]

 

the [NC,L] are conditions .. NC=no case, and L=last .. so once this condition (your RewriteRule is met, the script stops searching).

Ok i did that... it loads up http://www.runningprofiles.com/members/Admin fine but add http://www.runningprofiles.com/members/Admin/9 and it wont go to the page

you must enter a year in the URL, ie.

 

http://www.runningprofiles.com/members/Admin/9/2009/

 

each attribute of the rewrite must be met .. of course, you can create additional rewrites to accommodate different URL's.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.