crypticscs Posted August 5, 2021 Share Posted August 5, 2021 I made a website in PHP mvc framework. Now I want to remove "public" keyword from URL. I tried by removing require "../app/init.php"; these dots and bringing htaccess & index.php file in root directory. But it doesn't work. I searched on google but didn't find anything. Here is my index page code: Quote <?php session_start(); require "../app/init.php"; $app = new App(); and my htaccess code: Quote RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] Please give me a solution to it. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/ Share on other sites More sharing options...
gw1500se Posted August 5, 2021 Share Posted August 5, 2021 Not sure what is not working since you don't say what error you are getting. .htaccess is managed by httpd and has nothing to do with PHP or "bringing it in." It appears to me like 2 different problems. Let's start with problem one. What URL do you want to rewrite and what do you want the rewritten URL to be? Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/#findComment-1588875 Share on other sites More sharing options...
requinix Posted August 5, 2021 Share Posted August 5, 2021 6 hours ago, crypticscs said: Now I want to remove "public" keyword from URL. Are you saying that all your URLs are like https://whatever.example.com/public/filename.php? Is that because you have an actual public/ directory for your files? If so then it sounds like you need to tell Apache that your website should have its document root in that very same public/ directory... 1 Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/#findComment-1588882 Share on other sites More sharing options...
crypticscs Posted August 6, 2021 Author Share Posted August 6, 2021 I just want a url like domain.com which is currently in domain.com/public. When I put index page in root directory it is showing me 500 server error Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/#findComment-1588892 Share on other sites More sharing options...
crypticscs Posted August 6, 2021 Author Share Posted August 6, 2021 16 hours ago, requinix said: Are you saying that all your URLs are like https://whatever.example.com/public/filename.php? Is that because you have an actual public/ directory for your files? If so then it sounds like you need to tell Apache that your website should have its document root in that very same public/ directory... Yes. I just want my URL like https://whatever.example.com. I tried to do so by putting index and htaccess file in root directory but it is not working. I tried to get a solution but I didn't get any. Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/#findComment-1588893 Share on other sites More sharing options...
requinix Posted August 6, 2021 Share Posted August 6, 2021 4 hours ago, crypticscs said: Yes. I just want my URL like https://whatever.example.com. I tried to do so by putting index and htaccess file in root directory but it is not working. I tried to get a solution but I didn't get any. Did you read the part of my post that said what it is you need to do? Not by moving files but by changing the Apache configuration. The key words in there were "document root". Quote Link to comment https://forums.phpfreaks.com/topic/313501-url-setting/#findComment-1588897 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.