httaccess change mydomain.com/knowledgebase.php to mydomain.com

Viewed 51

I checked many other similar questions but I can't come up with a .htaccess rule that would work properly.

I have a server containing a Knowledgebase system (knowledgebase.php). I don't want to show this knowledgebase.php in the URL, ever.

Examples what I want:

How can I do this?

I tried many options, including this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /knowledgebase.php?/$1 [L]
2 Answers

Could you please try following, written based on your shown samples. Please clear your browser cache before testing urls.

RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/?$
RewritewriteRule ^ knowledgebase.php [L]

RewriteCond %{REQUEST_URI} ^/(knowledgebase) [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/?article=1 [L]

You can use this :

RewriteEngine on
#1) redirect "help.thecrypto.app/" to /knowledgebase.php
RewriteCond %{HTTP_HOST} ^help.thecrypto.app$ [NC]
RewriteRule ^knowledgebase\.php$ / [L,R]
#2) internally map knowledgebase.php to the root /
 RewriteRule ^/?$ /knowledgebase.php [END]

This will serve /knowledgebase.php if you visit your site hompage / .

Related