0

I have those rules in my .htaccess for redirect all requests to index.php. And it works. But i see pictures on second pages don't show. But pictures on main page are shown. How i can configure those rules additional?

Thanks.

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php
2
  • Define base href in <head> on every page and set it to your website url <base href="your-web-url.com"> Commented Sep 14, 2017 at 9:44
  • Do not use relative links anywhere! href="img/some-image.jpg" should be changed to href="/img/some-image.jpg". Give that a try. Commented Sep 14, 2017 at 9:46

1 Answer 1

1

This is the .htaccess I use

RewriteEngine On

# The following rule tells Apache that if the requested filename
# exists, simply serve it.

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]


# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

Also, do not use relative links anywhere! href="img/some-image.jpg" should be changed to href="/img/some-image.jpg".

Give that a try.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your help. I jast add "/" to front my link.
great! Can you mark this the correct answer please? :-)

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.