: Redirect 301 to a folder on the server? I wish to 301 redirect my conf file located at /etc/apache2/sites-available to a different folder on the server itself. But when I added: Redirect 301
I wish to 301 redirect my conf file located at /etc/apache2/sites-available to a different folder on the server itself. But when I added:
Redirect 301 / /var/www/web/public_html
to the conf file and restarted Apache2 I see the URL as:
www.example/var/www/web/public_html/var/www/web/public_html...
How can I 301 redirect to a folder and not a URL?
More posts by @Courtney195
1 Comments
Sorted by latest first Latest Oldest Best
While there is some overlap between the file system and the URL, that overlap only exists within the web space. /var/www/web/public_html is not within the web space. You cannot use this specification. You can only refer to anything within the public_html directory.
Taken what we discussed within the comments, use the code below in an .htaccess file within the public_html directory. Please know that any file with . and especially any file beginning with .ht will be hidden. You will have to have shell access (SSH) to your server.
> cd /var/www/web/public_html
> vi .htaccess
Of course you can use a control panel for this, however, I have no idea how to walk you through that.
Paste the following into your .htaccess file and save it.
RewriteCond %{REQUEST_URI} !^/index.html$ [NC]
RewriteRule .* /index.html [R,L]
Assuming that I got this right, the first line excludes any request not for /index.html and the second line takes those requests and redirects them to /index.html. In otherwords, if not /index.html then [show] /index.html.
If you want to see a listing of the files within your directory including hidden files, you can use:
> ls -al
In a control panel, there is an option to see hidden files within your file manager.
Of course this is only temporary until you figure out your website. Let us know how it goes.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.