Jump to content

Recommended Posts

Hey everyone,

 

Currently I have the following mod_rewrite:

 

RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

 

At the moment this converts any URL in the following format:

http://domain.com/pagename

to

http://domain.com/index.php?page=pagename

 

Works great! However, I need to get a 2nd parameter into my URL, but no matter how much I read on it and how much I tweak it (constant server errors etc) I can't get the following:

 

http://domain.com/firstpage/secondpart

to end up as

http://domain.com/index.php?page=firstpage&act=secondpart

 

Anyone able to point me down the right path? It's driving me mad!  :-\ This is the closest I think I've got, but still server error.

RewriteEngine On
//RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9]+)$ /index.php?page=$1&act=$2
RewriteRule ^([a-zA-Z0-9-]+)$ /index.php?page=$1

 

Regards,

Jason

Link to comment
https://forums.phpfreaks.com/topic/189943-expanding-my-mod_rewrite/
Share on other sites

Yeah, I figured that out after posting. Couldn't edit it though and didn't want to double post.

 

I've managed to not get an error to show, although now I just get a 404 error error with a 2nd variable. I actually want a 3rd one possible too if I can.

 

RewriteRule ^([a-zA-Z0-9-]+)/?$/^([a-zA-Z0-9]+)/?$ /index.php?page=$1&act=$2
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

 

I keep playing around with the symbols to try and get it to work but no joy :(

This is should work fine

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9]+)/?$ /index.php?page=$1&act=$2 [L]
RewriteRule ^([a-zA-Z0-9-]+)/?$ /index.php?page=$1 [L]

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.