Cr1xus
Cr1xus

Reputation: 437

How do I tell Rewrite that the link is GET and not a directory?

This is my code in .htaccess

RewriteEngine On

RewriteRule ^explore/([0-9a-zA-Z\ ]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z]+) renderpage.php?menu=$1&submenu=$2&subsubmenu=$3 [NC]

and when I type www.mysite.com/explore/Servizi%20ADR/Mediazione/Regolamento (excuse the italian)

  1. It takes forever to load
  2. When it finally loads and I 'inspect element' the source links for css and js are like if they were in "explore/Servizi%20ADR/Mediazione/Regolamento/jquery.js "

So my guess is I have to write something like a RewriteCond, but I don't know what exactly

Upvotes: 1

Views: 19

Answers (1)

Panama Jack
Panama Jack

Reputation: 24468

You should use conditions to not include real files or dirs. And also use a base path for files like this

RewriteEngine On
#if requested URI is real file or dir, do nothing
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

#else process the rule
RewriteRule ^explore/([0-9a-zA-Z\ ]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)/? renderpage.php?menu=$1&submenu=$2&subsubmenu=$3 [NC,L]

Also you can put the base tag in the head section of your html, instead of using absolute paths for your js and css.

<base href="http://www.yoursite.com" />

Upvotes: 1

Related Questions