William Smith William Smith - 6 months ago 36
HTML Question

How to remove URL rewriting for certain URLs

Back Story:
I am trying to make my own CMS, similar to Wordpress, I have enabled URL rewriting for my website with the following code in the .htaccess file:

RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page_name=$1 [NC,L]

I want to have an admin panel on someurlhere.com/admin which will show a proper dedicated admin panel back-end, using a dedicated php page and thus I don't want URL rewriting to work in this instance. How would I go about removing URL rewriting for the entirety of the /admin directory, using the .htacess file?


You can use a negative lookahead to skip admin:

RewriteRule ^(?!admin)([A-Za-z0-9-]+)/?$ index.php?page_name=$1 [NC,L,QSA]