Mitja MIKLAV
Mitja MIKLAV

Reputation: 83

.htaccess multi URL rewriting

I have this rule:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ profil.php?upime=$1

and it is working. Now I want to know how to rewrite the URL of another page:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ profil.php?upime=$1
RewriteRule ^(.*)$ novica.php?nid=$2 - I did this, but is not working.

what can I do that I will have both rules in one .htaccess file?

Upvotes: 4

Views: 481

Answers (1)

jeroen
jeroen

Reputation: 91734

You cannot do it like in your example as you are rewriting everything: ^(.*)$.

If you want two different rules, you would need to select what urls you want to write to what end destination.

An example where you rewrite different urls that start with different strings to different destinations:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^starts_with_this(.*)$ profil.php?upime=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^starts_with_something_else(.*)$ novica.php?nid=$1

Upvotes: 5

Related Questions