user56725
user56725

Reputation:

MODX custom .htaccess rewrite rule OR dynamic URLs

I need a dynamic seo-friendly URL.

/portfolio/tags/communication should give me communication as a filter parameter. I tried to rewrite the url like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule portfolio/tags/(.*)$ portfolio/tags?filter=$1 [N]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

But no success so far. Are there other possibilities to have a dynamic url in modx?

Upvotes: 1

Views: 499

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

It looks like the order of your directives is wrong. Rewrite conditions only get applied to the immediately following rule, and you need your conditions to be applied to the index.php routing rule. So try:

RewriteRule portfolio/tags/(.*)$ portfolio/tags?filter=$1 [L,N]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Upvotes: 0

Related Questions