Jump to content

Recommended Posts

So I heard of mod_rewrite a few days ago, and would love to implement it on my site.

I can rewrite some basic ones, but I'd like to keep it simple and I don't know how..

 

My whole page consists of an index.php page

Then there's the basic ones:

index.php?fx=activities

index.php?fx=somethingelse

 

Those I have managed to rewrite to mydomain.com/activities    using:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?fx=$1  [NC,L]

 

The tricky part is where I have multiple $_GET[]'s

for example:

index.php?fx=photos&album=whatever

and:

index.php?fx=contact&info=whatever

 

How do I manage this? Is it possible? I know I could use

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?fx=$1&album=$2  [NC,L]

But that would make it work only for the photos, and actually it doesn't even do that...

 

Is it possible to change this with mod_rewrite, or should I change the general layout of my $_GET[]'s with more universal ones?

Link to comment
https://forums.phpfreaks.com/topic/222136-mod_rewrite-trouble/
Share on other sites

  • 1 month later...

It needs to know if you want the album or info page. They can't both have the same kind of URL. Adding a fake directory will fix it.

 

Options +FollowSymLinks +Indexes

RewriteEngine on

RewriteBase /

RewriteRule ^fx/([^.]+)/album/([^.]+)$ index.php?fx=$1&album=$2  [NC,L]

RewriteRule ^fx/([^.]+)/info/([^.]+)$ index.php?fx=$1&info=$2  [NC,L]

RewriteRule ^([^.]+)$ index.php?fx=$1  [L]

Link to comment
https://forums.phpfreaks.com/topic/222136-mod_rewrite-trouble/#findComment-1163460
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.