Jump to content

Recommended Posts

Hello forum -

 

I have a RewriteRule that I have been using for a while which has served me well:

 

RewriteRule ^([^\/]+)\/?$ main/?login=$1

 

This allows me to to take

 

http://mydomain.com/main/index.php?login=username

 

... and rewrite it to the following:

 

http://mydomain.com/username

 

As I said, all has been well until I started coding up my calendar page which has an additional variable ($event) tacked on to the URL. This is the actual, unwritten URL structure

 

http://mydomain.com/main/calendar/view.php?login=username&event=2

 

that I need to rewrite back to

 

http://mydomain.com/username/calendar/view.php?event=2

 

I have currently come up with the following RewriteRule

 

RewriteRule ^([^\/]+)\/calendar\/view.php([0-9]+)?$ main/calendar/view.php?login=$1&event=$2

 

which works fine for the login variable but it doesn't pass the event one. This will pull up the web page correctly, URL wise, but won't acknowledge the $event variable at all.

 

I have read through several tutorials already trying to figure it out myself but have yet to get it working. Would anyone be able to show me what I'm doing wrong?

 

Thanks in advance!

After much digging and reading, I came up with this solution...

 

RewriteRule ^([^\/]+)\/calendar\/view.php?$ main/calendar/view.php?login=$1 [QSA]

 

which basically added the [QSA] to the end of the rule. Not sure if its the best way, but it works for now!

 

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.