Problem with URL rewriting (htaccess)

Good morning.

I currently have this little rule in my .htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^brochure/([0-9]+)$ /brochure.php?cat_path=$1 [L]

(I just use numbers, for example, here, there will be category names later.)

This redirects fine, but when this happens, everything I have in the directories now fails (css, js, images, includes, etc.)

I understand the problem (it discards the directory structure).

Changing the rule to this solves problems with images, css and JS.

RewriteRule ^([0-9]+)$ brochure.php?cat_path=$1 [L]

But that’s not what I really want.

What is the correct way to create URLs for rewriting and maintaining directory structures?

Thank you, I have a search on the previous questions, but I can not find a suitable answer.

+3
2

webroot, :

<img src="http://example.com/image.gif" alt="" />
<img src="/images/image.gif" alt="" />

, , :

<img src="../images/image.gif" alt="" />
+2

, . mod_rewrite /brochure.phpcat_path=123 /brochure/123. URL- . , , .

: css/style.css ../css/style.css

0

Source: https://habr.com/ru/post/1766526/


All Articles