Jump to content

.htaccess help?


peuge

Recommended Posts

Ok so I got this url when you enter the page

www.yoursite.com/index.php

now I have a menu with options such as Contact - Gallery - etc...

 

This menu sends a variable to index.php such that the address becomes

www.yoursite.com/index.php?choice=1

choice 1 is the gallery

 

So firstly I want to make that

www.yoursite.com/gallery

 

Secondly in the gallery I have thumbs.php and categories.php in a table with a large view of the picture clicked in the middle.

I need to send the variable when user clicks on a thumb to index.php or it just opens up gallery.

So when I click on a thumb the url reads

http://www.yoursite.com/index.php?pic=IMAGENAME&category=landscape/&&choice=1

 

where pic is the image name, category the category and choice keeps index in gallery.

I need the url to just say the category such as:

www.yoursite.com/landscape

 

Is there a way to do this in .htaccess? I have been googling but cannot seem to figure it out?

Thanks

Link to comment
Share on other sites

It's not intuitive to access a specific gallery category that way. And you also need to include the IMAGENAME somewhere.

 

My advice is to access them like this:

gallery - mysite.com/gallery/

gallery category - mysite.com/gallery/landscape/

gallery image inside category - mysite.com/gallery/landscape/imagename/

 

Something like this below would work for those examples. Just put the .htaccess file in your website root:

 

.htaccess

RewriteEngine on

RewriteRule ^gallery/$ index.php?choice=1
RewriteRule ^gallery/([a-zA-Z0-9]+)/$ index.php?choice=1$category=$1
RewriteRule ^gallery/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ index.php?choice=1$category=$1&pic=$2

 

Should get you started. If the category name and image name can contain anything other than alphanumeric characters, just alter [a-zA-Z0-9] accordingly.

Link to comment
Share on other sites

I will try to explain further:

 

I have

1) Gallery.php - include thumbs.php and categories.php all requests from these are sent to index.php

2) index.php - includes menu.php, gallery.php, home.php etc all requests from menu.php are sent to index.php

 

The reason I sent them to index.php is because I need the page to stay the same and only the relevant data to load in a table I created in index.php

 

No with all these pointing to index.php my url is always /index.php?SOMETHING.HERE

example:

/index.php?pic=images/landscape/big/como%2040%20x%2050%20(Large).jpg&category=landscape/&&choice=1

 

So now my question is with that information can I rewrite my urls to just be images/landscape/imgname?

or not?

 

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.