Zain SMJ
Zain SMJ

Reputation: 1632

Remove folder names from the URL using htaccess

I am stuck in here with htaccess. I've searched and tried many tutorials and problem solutions but couldn't achieve what I want.

I want to remove folder names from the website link. My htaccess file is in the root directory i.e "testing"

What my link looks like:

http://localhost/testing/sub/test.php

What I want:

http://localhost/test.php

Following is my htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /(.*) /testing/sub/$1    [L]

Upvotes: 3

Views: 5532

Answers (2)

Antonio
Antonio

Reputation: 1

The best way to do that is to go to the folder that contains all the files for your site . For example if the folder is named " site1 " go to it form your cpanel copy all the files to your Public_html folder

one way to do that is once you locate the folder that has your site files and you are looking at them , click on select all to select all the files or if you do not see select all click on the first file in the folder it should be highlighted then scroll down to the very last file of the folder press the shift button on your keyboard and click the last file now everything should be highlighted. if not repeat the process again until everything is highlighted .

right click and click on copy

on the little popup window on the bottom you should see copy file to make sure the folder you're copying the files to is /public_html then click on the copy files button on the lower right corner of the popup window .

all of your files should now be in the pulic_html folder you need to now change your configuration.php file right click on and click on edit once the popup window opens click on edit again it should open in your browser look for the code line that says :

public $live_site = 'http://vivendishop.com';

if your domain name has a /folder remove it and save

that should do it hope that works for you

Upvotes: 0

Adeel Sheikh
Adeel Sheikh

Reputation: 56

Use this line in your root .htaccess

RewriteRule ^test.php$ /testing/sub/test.php

Upvotes: 4

Related Questions