last day (15 days later) » 

9:48 PM
0
A: redirect subfolder , content and files to specific url link

anubhavaYou can use this rule in DocumentRoot/.htaccess: RewriteEngine On RewriteRule ^folder1/(folder.*|file.*\.html)?$ /folder2/file.html [L,NC,R=302]

 
sorry but i am trying to redirect all folders and files extenstions from /folder1 to /folder2/file.html and file.html is static name not randem and the asterisk * means all names in folders and files
 
ok see edited answer as per your changed question. Yes indeed * in your question means .* in regex
 
i tried this code when i go to folder1/ it redirect me to folder2 not folder2/file.html and when i go to folder1/file it gives me error 404 not found
 
Are you sure you placed it in /folder1/.htaccess? Are there more rules in that .htaccess?
 
it's only the code you post , but the folder2 have .htaccess codes . you can review it in this link pastebin.centos.org/12946
 
9:48 PM
What is the original URL you enter in your browser? Is it http://www.example.com/folder1/file.html? Do you want URL to change in browser or just an internal rewrite?
 
the original URL is example.com/folder1/file.html there is no parent directory than folder1 . and yes i want URL to change in browser and
 
ok try updated rule now.
 
unfortunately still not working but i changed the /folder2/file.html to full url link , it's works when i visit /folder1 . but it gives me 404 not found when i go to any link inside folder1 like folder1/file.html
Hello anubhava
 
Where is this .htaccess located?
 
it located in folder called dlili
and i want to redirect all content in the folder dlili to folder vb
not only folder vb but in static link in folder vb
like vb/f68.html
 
9:51 PM
ok can you copy/paste .htaccess here?
 
so i want to redirect everything in dlili if visitor come direct to site.com/dlili or site.com/dlili/file.html to site.com/vb/f68.html
the htaccess code no in the root directory of the website
RewriteEngine On

RewriteRule ^dlili/(folder.*|file.*\.html)?$ /vb/f68.html [L,NC]
 
so .htaccess is one level above /dlili folder?
 
yes correct
you can check live links
 
is there a .htaccess inside /dlili/ also?
 
the first link redirect successfully to sohbanet.com/vb/f68.html but the 2nd link redirect to sohbanet.com/vb not sohbanet.com/vb/f68.html
there is no .htaccess in dlili
 
9:58 PM
ok let me check
1st make rule as: RewriteRule ^dlili/(folder.*|file.*\.html)?$ /vb/f68.html [L,NC,R=302]
 
ok in root directory ?
 
yes
 
ok the .htaccess code now is
RewriteEngine On
RewriteRule ^dlili/(folder.*|file.*\.html)?$ /vb/f68.html [L,NC,R=302]
 
now when I entered http://www.sohbanet.com/dlili/file123.html it became http://www.sohbanet.com/vb/f68.html as per the rules
which URL isn't working for you?
 
ok i guess it's working not , i using IE on private browsing to make sure no url cached and seems it works let me try different links
that's weird i tried sohbanet.com/dlili/todo111.html i got 404
is that link sohbanet.com/dlili/todo111.html works for u ?
 
10:04 PM
http://sohbanet.com/dlili/todo111.html won't work because it doesn't match your pattern file*.html. Do you want all *.html to be redirected?
 
yes all html , and i don't want only html , i mean if people go to any file direct no matter if html , php or any other file it redirect the visitor to sohbanet.com/vb/f68.html
 
ok then use this rule: RewriteRule ^dlili/ /vb/f68.html [L,NC,R=302]
 
oh wow now it's working
wow u so good in htaccess rules
thanks so much
 
most welcome
 
and i apologies if i didn't clear my question very well
 
10:08 PM
no issues, glad it worked out. I updated the answer
 
thanks anubhava marked as answerd now
 
thanks and take care
 
you too anubhava
 
thanks & bye
 

last day (15 days later) »