2

I need some simple help with my htaccess file, thank you in advance.

I have a number website URLs, such as:

  • www.site.com/index.php?page_path=solutions-overview.html
  • www.site.com/index.php?page_path=solutions-a.html

I want to use the RewriteEngine to change the above links to the following respectively:

  • www.site.com/solutions/overview
  • www.site.com/solutions/a

Below is the .htaccess code I am using:

RewriteEngine On
RewriteRule ^solutions/overview index.php?page_path=solutions-overview.html
RewriteRule ^solutions/a index.php?page_path=solutions-a.html

This works, however all of my images, CSS files and JS files no longer load because the page is trying to fetch the wrong URLs. For example "/images/blah.jpg" is instead loading as "/solutions/images/blah.jpg".

How can I modify the htaccess code to prevent relative URLs from changing?

Thank you!

3
  • possible duplicate of mod rewrite and static pages Commented Jan 11, 2013 at 3:11
  • Ignacio's answer in is the general pattern for this... Commented Jan 11, 2013 at 3:12
  • Thanks but this didn't help. I cannot find a solution using htaccess. For anyone interested - I solved the issue by adding the following to the header of my HTML <base href="http://www.site.com/"> so that relative URLs are always resolved from this Commented Jan 11, 2013 at 4:25

1 Answer 1

4

Add this line <BASE href="http://www.yoursitename.com/"> to your page inside the <head> tag as follows:

<head>
    <title>Your site title</title>
    <BASE href="http://www.yoursitename.com/">
    ....
</head>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.