2

I'm having some trouble when applying rewrite rules to my pages.

My scheme is the following:

Assets (contains all subfolders with JS, CSS, IMG, etc)
header.php
footer.php
index.php (that have all links to all other files -> index.php?id=page

Now, I'm having some troubles when creating a rewrite rule with second level. For example, I have the page:

edit-language -> that opens the page index.php?id=edit-language

This page lists all languages and have some options to user choose:

edit-language/delete/X -> opens the same page above but with &delete=X -> both X are the ID
edit-language/publish/X -> opens the same page above but with &publish=X -> both X are the ID

Now, The rewrite rule I have for main page:

RewriteRule ^edit-lang/?$ index.php?id=edit-lang [L]

And this works just fine, but when I create the rule for another level /something/something it lost all CSS files. For example:

RewriteRule ^edit-lang/delete/(.*)$ index.php?id=edit-lang&delete=$1 [L]

All my assets are being loaded in header and footer PHP files like src="assets/js/..."

Can someone help me please? Thanks!

1 Answer 1

1

I'll take a guess here - you are using relative links?

src="css/some.css"

This looks from the current folder. As you are now on a different folder level, the files are not available and will 404.

Always use an absolute link starting with a slash like so:

src="/css/some.css"

This way it will start looking from your site root, and shouldn't 404 any more.

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

1 Comment

You was absolutely right. That was a stupid error from my side. I have all sources with absolute link except two of them (main css and js). Thanks for your time.

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.