I am stuck in a problem where the code redirects as expected but it is causing other urls to show 404.
Here is my htaccess code:
RewriteEngine On
RewriteBase /
RewriteRule ^category/(.*)$ catlinks.php?id=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*)$ show.php?id=$1 [QSA,L]
WHen I change RewriteRule ^category/(.*)$ catlinks.php?id=$1 [L] to RewriteRule ^(.*)$ catlinks.php?id=$1 [L] it works as expected by removing category slug from url.
the above code changes the slug from domain.com/abc/xyz to: domain.com/xyz
THe category function is working as expected but this rule is causing other links on website to show 404
THe first thing I want:
RewriteRule ^(.*)$ show.php?id=$1 [QSA,L]
this redirects the show.php?id=$1 to domain.com/abc but with above category rule it is not working.
then, I have an admin page which is accessible by: domain.com/admin/login.php (admin slug remains in all pages of admin panel) but above code causes the admin panel to show 404
So, in short here is what I want:
- remove category slug from url which should show category as domain.com/abc whereas currently it is: domain.com/category/abc
- THe admin page should be accessible whenever I add /admin to domain and all its pages should work i.e. domain.com/admin/login.php, domain.com/admin/products.php
- The product page show.php?id=$1 should work fine and redirect to domain.com/abc
I am not a pro in htaccess so stuck in it.
Help please.