I want to know, what to write in my .htacess file for rewriting my urls.
I want :
* folder pointed : exemple.com/subfolder
* And the visible url : exemple.com/
Corrections:
I have my domain exemple.com pointing to public_html directory. My website is on exemple.com/subfolder. I want to go to the url exemple.com, I want it to show the content of exemple.com/subfolder but with exemple.com shown as url
Thank you
Related
I just want to redirect this kind of URL :
mydomain.fr/public/pages/project.php
To this kind of URL
mydomain.fr/project.php
I'm trying this kind of stuff in my .htaccess file
Redirect /public/pages/ http://mydomain.fr/
OR
RewriteEngine On
RewriteRule ^public/(.*)$ /$1 [L,NC,R=302]
(to remove just the 'public' folder).
Its working so when I click on a link of my website, the URL is redirected to what I want, but it broke the navigation. So I can't access my page (error like : The requested URL was not found on this server.) occured.
My question : How do I remove these subfolder in my URL without removing these subfolder into the server of my website ? I dont know if i'm clear, sorry my english is not perfect.
Thanks !
Have a good day
I have a order page in the following path
https://example.com/backend/web/order
And I want to display it as
https://example.com/order
What should be the htaccess code (please let me know of every step if possible so I can learn also). Where should I place the htaccess file? Inside the backend folder or the root folder.
To change https://example.com/backend/web/order to https://example.com/order you can use the following rule in htaccess in your root folder :
RewriteEngine On
RewriteRule ^order /back-end/web/order [L]
The rule above makes it possible to access your old URL as http://example.com/order .
I have a site https://sitename.com/web (example). So, full path to page is sitename.com/web/index.php. On ftp server there is folder /web which also contain second page file - index-2.php. How to avoid creating /web-2/ folder and redirect index-2.php to sitename.com/web-2 ?
Easy, create an .htaccess file inside the root folder of your site, then add the following lines to it:
RewriteEngine On
RewriteRule ^web-2$ index-2.php [QSA,L,NC]
This site might help you with htaccess:
https://www.htaccessredirect.net/
A nice tutorial on .htaccess files also below:
https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file
I have had to change the name of a page on my wordpress site. In the url structure the page has many sub pages which are illustrated as follows:
www.mysite.com/folder1/plus whatever else may come here
Basically I want to do a wildcard redirect where any URL matching the folder1 part of the URL gets caught and redirected to the following:
www.mysite.com/newfolder1/folder2/
The following redirect works for the above situation
RewriteRule ^folder1/?(.*) http://www.mysite.com/newfolder1/$1 [R=301,L]
But fails and give a 404 for the following
www.mysite.com/folder1/folder2/folder3
It will not redirect beyond the folder2 depth. Why is this?
Following up on the comments:
The problem sounds like the .htaccess file (or the rules you're talking about) is in the wrong location.
As far as my understanding goes, Apache reads all the .htaccess files (and other server configs that do redirects) from the "top" down - i.e., .htaccess files in subfolders are processed after .htaccess files in the root folder.
I have an "addon domain" with no specified htaccess file but the main site (of which the add on site is a sub dir) DOES have htaccess which rewrites url to remove the .html prefix.
Anyhow when i go to the addon domain for instance: test.com/about.html it automatically changes to test.com/test.com/about.html
Can anyone point me in the direction to correct this?
If there is no htaccess file with modRewrite in it in a directory, apache goes up to the parent directory to search for it, and this goes up along the tree (this is not affected by having an addon domain or not). So that means that your addon domain is affected by the htaccess file of the parent domain.
What you need to do is create an htaccess file in the subdirectory (the addon domain) and desactivate rewriting :
RewriteEngine Off
Or you can add your own RewriteRules if you want.