简体   繁体   中英

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

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]

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 / .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM