Jump to content

[SOLVED] Url Rewriting issues


Jagarm

Recommended Posts

Hello all,

 

I currently have url writing on my site, it takes index.php?action=something into host.com/something. Everything is good there, now i have some sites that requires me to pass additional queries to the script such as follow: index.php?action=movies&page=2.

 

What I'm trying to do is have it like this host.com/something/2

 

So far I have the following and I've been trying for days but no luck in doing that.

 

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?action=$1 
RewriteRule ^(.*)/(.*)$ index.php?action=$1&page=$2 

 

I don't know what I am doing wrong there, but I would appreciate some help.

 

As you may know not all the time it will need the page string but sometimes so I tried to make it optional as follow:

RewriteRule ^(.*)(/(.*))?$ index.php?action=$1&page=$3

but it doesn't work.

 

I would appreciate any help.

 

Also is it possible to automatically based on the htaccess to change it from index.php?action=movies into /movies or /movies/34

 

Thanks,

Link to comment
Share on other sites

I'm still trying to get this to work, so far I have the following code

 

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)(/(.*))?$ index.php?display=$1&n=$3 [QSA]

 

This works if the &n is specified even though I made it optional that is if its:

http://www.beta.berwari.net/index.php?display=movies&n=20

 

the display argument will contain "music,movies,links,contact" so only for movies there will be the &n argument specified that is for pagination page number.

 

Please let me know if anything is not clear,

 

I really need help with this, since i"m been trying for days with no luck.

 

Thanks again

Link to comment
Share on other sites

This is what I was looking for and thanks to http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site

 

I found the way, this is how I done it, in case somebody like me is trying to search for something simlar

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?display=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?display=$1&n=$2 [L]

 

Thanks to those who looked at my post

Link to comment
Share on other sites

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.