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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:46:53+00:00 2026-06-01T11:46:53+00:00

I made an website with php and I wrote .htacess file in my htdocs

  • 0

I made an website with php and I wrote .htacess file in my htdocs folder:

RewriteEngine on 
RewriteBase /

RewriteRule ^([a-zA-Z0-9]+)/?$ ?mainquery=$1 [QSA]

RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ ?mainquery=$1&subquery=$2 [QSA]

My Intention is to redirect the url:

‘/A/B’ => ‘/?mainquery=A&subquery=B’.

If the main query is one, everything works fine.
but when the url has two queries, php works fine, but the folder hierarchy moves, so every images and css files with relative urls doesn’t work.

It works fine that

(I’m building my web on MAMP, so the domain is now localhost.)

‘localhost/publications/articles’ => ‘localhost/?mainquery=publications&subquery=articles’

but the html thinks the main url is ‘localhost/publications’, not just ‘localhost/’.

so every img tag which has src attribute like

img src=’images/myImage.jpg’

doesn’t work, because the html thinks the image is in ‘localhost/publications/images/’, not ‘localhost/images/’.

So does css file.

I’m pulling my hair for 3 days, but I can’t solve it myself.

How can I solve this problem?

  • 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-01T11:46:54+00:00Added an answer on June 1, 2026 at 11:46 am

    Change this line:

    RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ ?mainquery=$1&subquery=$2 [QSA]
    

    To this:

    RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ /?mainquery=$1&subquery=$2 [QSA]
    

    The rewritten rule need to be root-relative, else it’s going to be relative to the requested URL, which is in a sub-folder already.

    I think that’s what you’re asking. If you’re just asking how to point to images/css/js root-relative, change this:

    <img src="images/myImage.jpg" />
    

    To this:

    <img src="/images/myImage.jpg" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website built in PHP 4 with a framework made by hand
I have made a C# application that talks to my website via PHP(mcrypt) and
I have a website running on the root folder of my host /index.php I
I'm working on my website made from php, and my programmer put the following
Ok. I recently made some updates to this website. http://annberingerart.com/index.php Upon making some minor
I made a website that depends on PHP, AJAX and Javascript. The problem here
I made a simple database driven php website. Now i am trying to implement
I recently started with the unit testing for my php website made in CodeIgniter
I have made an eCommerce website using php/mysql. The root currency I have used
I need to do some testing for a website made in php/mysql and wanted

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.