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 8883503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:49:40+00:00 2026-06-14T20:49:40+00:00

I’m trying to rewrite urls for a page that has two query strings parameter.

  • 0

I’m trying to rewrite urls for a page that has two query strings parameter. And according to these parameters value (set or not), I show different contents on the page.

example.com/fotograf.php?aid=10
example.com/fotograf.php?aid=10&fid=5

The URLs above are the examples to not rewrited ones. I just want to make them such that

example.com/fotograf/10/
example.com/fotograf/10/5/

The first URL links to the album with photos, and the second one links to a photo in that album.

In .htaccess, I just want to be able to reach them with the clean URLs above. After that, I will check the URL at the top of the script and if it’s not clean then with a function I wrote I will redirect it to clean one (by getting values with preg_match and preg_split and redirecting with header function).

So far, I have tried this rule (which did not work to view album):

RewriteRule ^fotograf/([0-9-/]+)/([0-9]+)/?$ fotograf.php?aid=$1&fid=$2 [L]

Then, this (which redirects to album always):

RewriteRule ^fotograf/([0-9-/]+)/?$ fotograf.php?aid=$1 [L]

Finally, this (helped me to view the photo by a URL like example.com/fotograf/10/?fid=5):

RewriteCond %{QUERY_STRING} ^fid=(.*)$
RewriteRule ^fotograf/(.*)/$ fotograf.php?aid=$1&fid=%1

But I don’t want to see any question marks or ampersands in the URL.

Somehow, I need to check which one(s) is(are) set and redirect accordingly but I just don’t know how to achieve this.

How can I do this?

Thanks in advance.

  • 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-14T20:49:41+00:00Added an answer on June 14, 2026 at 8:49 pm

    You need to make your application to generate the URLs like you want them, so in the form:

    example.com/fotograf/10/
    example.com/fotograf/10/5/
    

    and following rewrite rule will make sure, it’ll reach your php:

    RewriteEngine On
    
    RewriteRule ^fotograf/([0-9]+)/([0-9]+)/?$ fotograf.php?aid=$1&fid=$2
    
    RewriteRule ^fotograf/([0-9]+)/?$ fotograf.php?aid=$1
    

    mod_rewrite can’t rewrite URLs in your HTML pages…

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.