Apache URL rewrite - attempt to mask a folder name

I have a website located in example.com/cmsFolderwhich I want to move to example.com/newFolder. I cannot manually move this as it completely destroys this stupid CMS.

So, I'm trying to use mod_rewriteto hide the folder name and keep it in good condition.

RewriteEngine on
RewriteRule ^cmsFolder/(.*)$ /newFolder/$1 [L]

Error with 404. How can I hide the folder name?: /

+3
source share
4 answers

Try it, it works for me, adding these rules to the main Apache configuration file:

RewriteEngine on
RewriteRule ^/cmsFolder/(.*)$ /newFolder/$1 [L]

I think you forgot the first slash before cmsFolder. If you want to see the mod_rewrite logs:

RewriteLog "_PATH_TO_YOUR_\rewrite.log"
RewriteLogLevel 9

Paolo, .htacces. , : -)

Edit:

, , [P] (Proxy):

RewriteEngine on
RewriteRule ^/cmsFolder/(.*)$ /newFolder/$1 [P]
+4

newFolder cmsFolder

ln -s cmsFolder/ newFolder

PHP script, :

<?php symlink('cmsFolder','newFolder'); ?>
+1

If you want to rewrite requests /newFolder/โ€ฆinternally before /cmsFolder/โ€ฆ, you need to go the other way around:

RewriteEngine on
RewriteRule ^newFolder/(.*)$ /cmsFolder/$1 [L]
0
source
RewriteEngine on
RewriteCond %{REQUEST_URI} !^subfolder/login
RewriteRule ^login/(.*)$ subfolder/login/$1 [L]
-1
source

Source: https://habr.com/ru/post/1732312/


All Articles