N
N
neoneel2017-02-20 22:19:09
htaccess
neoneel, 2017-02-20 22:19:09

How to hide file extension and folder in url?

how to hide file extension and folder in browser address bar
example:
site.ru/directory/file.php change to site.ru/file ?
now the htaccess file looks like this:
RewriteRule .* index.php [L]
RewriteCond %{REQUEST_URI} ^/directory/.*$
RewriteRule ^directory/(.+)$ site.ru/$1 [L,NC]
tried to prescribe below:
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^.]+)\.phpl\ HTTP
RewriteRule ^([^.]+)\.php$ site.ru/$1 [L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteRule (.*) /$1.html [L]
will eventually only work if the condition
RewriteRule ^directory/(.+)$ site.ru/$1 [ L,NC] - absent
those. I managed to hide either the folder or the extension, but I can’t convert everything together ... what are the options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-02-21
@shambler81

the task is a little not clear, vsmysle to hide the extension and the folder?
folder in the format ? .php folder or where?
For exceptions, you can use

т такие замечатлеьные штуки
 RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d

Negatives work for any conditions.
I also ask you to provide 5-6 links of what should turn into what. I will write a regular expression and explain what and why.
While you have porridge ;(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question