C
C
Cozyr2016-05-15 12:14:51
Apache HTTP Server
Cozyr, 2016-05-15 12:14:51

How to solve the problem with redirects in Mod_Rewrite?

Good afternoon, dear =)
Let me get straight to the point: I have a folder with all the modules in the root of the site, for example, /content/.
Each folder (forum, blogs, games, etc.) contains everything necessary for the module to work (files, templates, handlers, classes, styles, etc.). And of course there are beautiful links, for example:
site.ru/forum/theme543
site.ru/blogs/post543
Until today, I specified the path to each file in each module in the root .htaccess:

# включаем mod_rewrite
RewriteEngine On
RewriteBase /content/

# форум
RewriteRule ^forum/theme([0-9]*)$ forum/theme_view.php?id=$1 [L,NC,QSA]
и еще 24 ссылки

# блоги
здесь около 15

# игры
здесь n-количество ссылок

And as you understand, there are so many links that I thought about how to reduce them in the root htaccess (otherwise I start to get confused). And here's the problem: is it possible to somehow redirect the request from the root .htaccess via mod_rewrite to the .htaccess module, so that it "picks up" and processes links there. I will explain with an example of the following code:
root .htaccess
# включаем mod_rewrite
RewriteEngine On
RewriteBase /content/

RewriteRule ^forum/theme([0-9]*)$ forum/ [L,NC,QSA]

and in .htaccess module
# включаем mod_rewrite
RewriteEngine On
RewriteBase /

RewriteRule ^forum/theme([0-9]*)$ theme_view.php?id=$1 [L,NC,QSA]

Would it be possible to do this at all? If not, what alternative solutions can be found?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-05-16
@Cozyr

well, for this you need to do the following...
Nothing!
.htaccess is how it works.
All you have to do is create a .htaccess file inside the folder you need.
Also, it would not be sour to bring the entire .htaccess because it’s not clear.
As for the number of lines, I have an average of about 6K lines per store and I measured nifiga does not slow down.
As for optimization, let's think about the whole file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question