0

I have two questions im struggling with :

  1. I have a static web pages in the following directory of my apache :

var/www/folder/

I have managed to redirect my domain to the above folder to load the html pages, however the when I go to the domain the url shows domain.com/folder Now I understand I need to change the sites-available in the etc/apache2 folder in order to directly hit the domain.com however im trying to achieve it without having to change the etc/apache2 sites-available. Is there a way?

The reason I do not want to change the sites-available is because there is a folder2 inside www which I need to access at some point. How do I redirect the domain without showing the folder on the url?

  1. Inside the www/folder/ I have a few php pages, Now I have tried using .htaccess in the www and inside www/folder/ to remove the .php from the url, however it doesn't seem to work. How do I remove the .php extension from the url?

Thanks in advance.

Aaditya Damani
  • 355
  • 1
  • 2
  • 12

1 Answers1

1

If you want to remove the folder name from the URL then you should check this link. It has almost same issue, that you are facing.

how to remove folder name from url using htaccess

Beside this to remove .php Extension use this :

Option 1 :

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]

Option 2:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html
ARVIND IT
  • 156
  • 1
  • 9