Mobile app version of vmapp.org
Login or Join
Courtney195

: 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

@Courtney195

Posted in: #301Redirect #Apache2 #Configuration #Redirects

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Courtney195

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme