Reputation: 182
This is my .htaccess file:
Options +FollowSymLinks -MultiViews
AuthType Basic
AuthName "website"
AuthUserFile ""
require valid-user
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /article.php?slugId=$1 [L]
I want to add the following:
RewriteRule ^([^/]+)$ /category.php?category=$1 [L]
Adding this line at the end produces a server error since they both match the same. Both rules aim to change the URL of different files in the same folder.
What I want is to hit the following link
website.com/y
where y could load category.php?category=category1
and also have
website.com/x
where x could load article.php?slugId=some-slug
article.php and category.php would be two different files in the same folder.
How can I change the rules to make them work?
Upvotes: 1
Views: 646
Reputation: 133528
Could you please try following, written as per your shown samples.
In following solution:
firststring
with string which you want to look in URI while rewriting it to article.php
in backend.secondstring
with string which you want to look in URI while rewriting it to category.php
.
Options +FollowSymLinks -MultiViews
AuthType Basic
AuthName "website"
AuthUserFile ""
require valid-user
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1 !-f
RewriteCond %{REQUEST_URI} firststring [NC]
RewriteRule ^([^/]+)/?$ article.php?slugId=$1 [L]
RewriteCond %{DOCUMENT_ROOT}/$1 !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} secondstring [NC]
RewriteRule ^([^/]+)/?$ category.php?category=$1 [L]
Upvotes: 2