Leonardo
Leonardo

Reputation: 155

Rules being overwriten on .htaccess

I'm trying to create some rules using .htaccess:

i would like to do:

The .htaccessfile content is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# RULES FOR BLOG

RewriteRule blog/(.+)$                      ./src/components/blog/index.php?url=$1 [L,QSA,NC]

# RULES FOR LANDING PAGE

RewriteRule ([a-z\-_0-9]+)/([^/.]+)$        index.php?module=$1&url=$2 [QSA,NC]
RewriteRule ([^/.]+)$                       index.php?url=$1 [QSA,NC]

The problem is

Always it's redirect to ./index.php - i can't access blog.

How i can make the rules not be overwriten?

Upvotes: 1

Views: 16

Answers (1)

Anonymous
Anonymous

Reputation: 12017

You're missing the ^ start anchor on your rules so they match URLs that they shouldn't:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# RULES FOR BLOG

RewriteRule ^blog/(.+)$                      ./src/components/blog/index.php?url=$1 [L,QSA,NC]

# RULES FOR LANDING PAGE

RewriteRule ^([a-z\-_0-9]+)/([^/.]+)$        index.php?module=$1&url=$2 [QSA,NC]
RewriteRule ^([^/.]+)$                       index.php?url=$1 [QSA,NC]

Upvotes: 1

Related Questions