N
N
Nyakator2017-03-29 16:34:01
Apache HTTP Server
Nyakator, 2017-03-29 16:34:01

Is it possible to redirect with htaccess without changing the path after the domain name?

On a shared hosting, I would like to set up a redirect of all requests to www.sitename.ru/public/index.php so that www.sitename.ru remains in the address bar.

Now the .htaccess file looks like this.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|css|js|ini|png|jpg|gif|robots\.txt)
RewriteRule .* /public/index.php [L]


The redirect happens, but the address also changes to www.sitename.ru/public/index.php

On dedicated hosting, I specified /public/ as the parent directory and everything worked as it should. Can this be achieved on shared hosting?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-03-29
@Nyakator

<IfModule dir_module>
    DirectoryIndex  index.php index.html index.htm
</IfModule>

you at once not about it?
Second decision
RewriteCond %{REQUEST_METHOD} =GET
RewriteCond %{REQUEST_URI} ^(.*)/index\.php$
RewriteRule ^(.*)$ %1/ [R=301,L]

before cnc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question