S
S
Sergey Chi2016-02-22 23:13:34
htaccess
Sergey Chi, 2016-02-22 23:13:34

How to redirect without changing the url?

Now the contents of the .htaccess file looks like this:

AddDefaultCharset windows-1251

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

What should the .htaccess file look like completely so that the following rules are observed:
- when entering the mysite.com pages , a redirect to www.mysite.com occurs
- when entering the pages mysite.com/products , mysite.com/photos , a redirect occurs to www.mysite .com/products and www.mysite.com/photos , and the same thing would be displayed as on the www.mysite.com page (only these 2 options products and photos)
- after the operation of these rules, ajax requests like www.mysite.com/server/query.php - pages like www.mysite.com/somefolder
did not stop opening after these rules were triggered, where in the somefolder folder is the index.php file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-02-26
@shambler81

RewriteEngine On
RewriteBase /
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^products$ http://www.%{HTTP_HOST}/products [R=301,L]
RewriteCond %{HTTP_HOST} !^www\. (.*) [NC]
RewriteRule ^photos$ http://www.%{HTTP_HOST}/photos[R=301 ,L]
Now how to shove the non-pushable.
you want to change the url but not change it, and vice versa, which is kind of stupid.
But nevertheless, the substitution of files can be done without touching the site engine at all.
But this can be done in nginx in proxy mode. in this case, it will physically replace the folders, but the urls will not change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question