Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:26:35+00:00 2026-06-10T18:26:35+00:00

I did some searching around, but I’m not very experienced in PHP, so I

  • 0

I did some searching around, but I’m not very experienced in PHP, so I don’t know the correct Terms/Words I am looking for.
However, I do have a good idea of what I want to do.

  1. I have a website with many images, each image has a database entry (MySQL).
  2. I would like each image to have its own landing page, based on its database values. (Title, Category, Tags, etc…)
  3. I don’t want to make a separate .php file on my server for each image. (Eg: pinkflowers.php, redroses.php, etc…)
  4. There should be 1 PHP template file, that outputs the webpage for ALL images, based on the URL (variable) that the user visits.

So if someone visits “mysite.com/pinkflowers.php”, the page should be output with the variables of pinkflowers from my database.

However, the file pinkflowers.php doesn’t actually exist, only template.php exists, which would be the “blueprint” for all the images in my database.

  1. I would like the .php to be removed from the URL in the browser.

    “mysite.com/pinkflowers.php” => “mysite.com/pinkflowers”

    I already have code that does this with my existing pages (below); I’m not sure if it will also work with these “imaginary” pages.

    (.htaccess)    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    
  2. If the user tries to visit a page that has no related database entry (eg: “mysite.com/430jfif0ij”), they should be re-directed to the homepage.

I’m not expecting anyone to give me ALL the answers, but please at least guide me in the right direction to begin making such a template.
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:26:37+00:00Added an answer on June 10, 2026 at 6:26 pm

    I was able to solve my own question eventually, in the mean time that no Answers were given.

    I followed this Tutorial here:
    http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

    My .htaccess contained:

    RewriteEngine on    
    Options +FollowSymLinks
    
    RewriteCond %{SCRIPT_FILENAME} !-d  
    RewriteCond %{SCRIPT_FILENAME} !-f  
    
    RewriteRule ^category1/(.*)$ ./template.php?image=$1
    RewriteRule ^category2/(.*)$ ./template.php?image=$1
    RewriteRule ^category3/(.*)$ ./template.php?image=$1
    etc...
    

    category# – being the “folders” that my images are categorized by.

    I did this on the template.php to extract the Variable from the URL:

    $result = mysql_query('SELECT * FROM image_list WHERE image_name="' . mysql_real_escape_string($_GET['image']) . '"');
    

    To redirect the visitor to the Homepage if they enter an invalid URL/ID, I used this:

    if (mysql_num_rows($result)==0) {
    echo "<script>window.location = 'http://mysite.com/'</script>";
    }
    

    So the combination of all these methods achieved exactly what I was looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did some searching around but I can't seem to find any information on
First of all, I did some searching for an answer to this question...but I
I did some searching but it wasn't what I was looking for. So, does
I did some searching but haven't landed anything that looks useful yet but I
I did some searching and was not able to find any information regarding this
sorry, I did not find something useful when searching google. Very basic question, mainly
My apologies if this has been answered before or is obvious...did some searching here
I did some research but all I could find was syncing data core with
I did some searching and didn't find a question that directly answered this question.
Apologies if this was answered elsewhere -- I did some searching and couldn't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.