B
B
BonBon Slick2016-08-15 20:47:14
Apache HTTP Server
BonBon Slick, 2016-08-15 20:47:14

Why can't I make a nice mod_rewrite link?


http://blog/view/site/home.php
I'm doing it on the local host, there is a site, through a bunch of folders a view, now after entering the site the link is this blog/home
:

RewriteEngine On

- RewriteRule ^/view/site/home.php$ test.php
- RewriteRule ^/view/site/home.php$ index.php
- RewriteRule ^/view/site/home.php$ home  [L,QSA,NC]
- RewriteRule ^/view/site/home.php$  home.php
- RewriteRule ^view/site/home.php$ home.php   [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f

And a bunch of other variations, please explain how to do it right, otherwise I understand, but nothing works.
What comes after ^will be changed to what comes after php$in our change, and the array is the parameters by which the conversion takes place, but I don’t understand something exactly how it works out ...
I tried according to the article on Habré.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-08-17
@shambler81

how many have not sat on the toaster, but have not seen this one ..
You thoroughly need to read the mod rewrite.

# если  это не !  директория
RewriteCond %{REQUEST_FILENAME} !-d  
#И если  не файл
RewriteCond %{REQUEST_FILENAME} !-f

That ??? then what should be? after the condos, there should be a rewrite wheel because after the conditions are met there should be a rule and you have conditions at the end, and even unnecessary ones.
i think you mean something like this
# если в урле встречается  /view/site что угодно+конец php
RewriteCond %{REQUEST_URI} ^/view/site/(.*)\.php&
# то  выполнить условие  $1 из реврайт когда будет %1
RewriteRule  (.*) /blog/%1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question